File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package logger
22
33import (
4+ "fmt"
5+ "os"
6+
47 "github.com/sirupsen/logrus"
58)
69
710var log = logrus .New ()
811
9- func init () {
10- log .Formatter = & logrus.TextFormatter {
11- TimestampFormat : "01-02 15:04:05" ,
12- FullTimestamp : true ,
12+ // @note custom plain formatter for cross-platform compatibility
13+ type plainFormatter struct {}
14+
15+ func (f * plainFormatter ) Format (entry * logrus.Entry ) ([]byte , error ) {
16+ timestamp := entry .Time .Format ("15:04" )
17+ level := entry .Level .String ()
18+
19+ switch entry .Level {
20+ case logrus .InfoLevel :
21+ level = "INFO"
22+ case logrus .WarnLevel :
23+ level = "WARN"
24+ case logrus .ErrorLevel :
25+ level = "ERROR"
26+ case logrus .FatalLevel :
27+ level = "FATAL"
28+ case logrus .DebugLevel :
29+ level = "DEBUG"
1330 }
31+
32+ msg := fmt .Sprintf ("%s - %s - %s\n " , level , timestamp , entry .Message )
33+ return []byte (msg ), nil
34+ }
35+
36+ func init () {
37+ log .SetOutput (os .Stdout )
38+ log .SetFormatter (& plainFormatter {})
39+ log .SetLevel (logrus .InfoLevel )
1440}
1541
1642func Info (args ... interface {}) {
Original file line number Diff line number Diff line change @@ -9,9 +9,23 @@ import (
99func main () {
1010 config .LoadConfig ()
1111
12- var config = config .GetConfig ()
12+ cfg : = config .GetConfig ()
1313
14- logger .Infof ("Configuration: %+v " , config )
14+ logger .Info ("=== Server Configuration ===" )
15+ logger .Infof ("Host: %s:%s" , cfg .Host , cfg .Port )
16+ logger .Infof ("Login URL: %s" , cfg .LoginUrl )
17+ logger .Infof ("Server CDN: %s" , cfg .ServerCdn )
18+ if cfg .ServerMeta != "" {
19+ logger .Infof ("Server Meta: %s" , cfg .ServerMeta )
20+ }
21+ logger .Infof ("Logging: %v" , cfg .Logger )
22+ logger .Infof ("Rate Limit: %d requests per %d minutes" , cfg .RateLimit , cfg .RateLimitDuration )
23+ if cfg .EnableGeo {
24+ logger .Infof ("Geo Location: Enabled (Regions: %v)" , cfg .GeoLocation )
25+ } else {
26+ logger .Info ("Geo Location: Disabled" )
27+ }
28+ logger .Info ("===========================" )
1529
1630 app := http .Initialize ()
1731 http .Start (app )
You can’t perform that action at this time.
0 commit comments