diff options
author | Wim <wim@42.be> | 2018-02-21 00:20:25 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2018-02-21 00:20:25 +0100 |
commit | d1227b5fc9de9f7a04fbf71292dd224aa8806411 (patch) | |
tree | 58d632c586fc3fc13783950f11265552f0f11dd5 /matterbridge.go | |
parent | 6ea368c383ccc19678623c51d8e4ecbbdb0a64ac (diff) | |
download | matterbridge-msglm-d1227b5fc9de9f7a04fbf71292dd224aa8806411.tar.gz matterbridge-msglm-d1227b5fc9de9f7a04fbf71292dd224aa8806411.tar.bz2 matterbridge-msglm-d1227b5fc9de9f7a04fbf71292dd224aa8806411.zip |
Use prefixed-formatter for better logging
Diffstat (limited to 'matterbridge.go')
-rw-r--r-- | matterbridge.go | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/matterbridge.go b/matterbridge.go index 0691a1f0..5e1e3f46 100644 --- a/matterbridge.go +++ b/matterbridge.go @@ -18,7 +18,8 @@ var ( ) func main() { - log.SetFormatter(&prefixed.TextFormatter{FullTimestamp: true}) + log.SetFormatter(&prefixed.TextFormatter{PrefixPadding: 10, DisableColors: true, FullTimestamp: true}) + flog := log.WithFields(log.Fields{"prefix": "main"}) flagConfig := flag.String("conf", "matterbridge.toml", "config file") flagDebug := flag.Bool("debug", false, "enable debug") flagVersion := flag.Bool("version", false, "show version") @@ -33,24 +34,24 @@ func main() { return } if *flagDebug || os.Getenv("DEBUG") == "1" { - log.SetFormatter(&prefixed.TextFormatter{FullTimestamp: false}) - log.Info("Enabling debug") + log.SetFormatter(&prefixed.TextFormatter{PrefixPadding: 10, DisableColors: true, FullTimestamp: false}) + flog.Info("Enabling debug") log.SetLevel(log.DebugLevel) } - log.Printf("Running version %s %s", version, githash) + flog.Printf("Running version %s %s", version, githash) if strings.Contains(version, "-dev") { - log.Println("WARNING: THIS IS A DEVELOPMENT VERSION. Things may break.") + flog.Println("WARNING: THIS IS A DEVELOPMENT VERSION. Things may break.") } cfg := config.NewConfig(*flagConfig) cfg.General.Debug = *flagDebug r, err := gateway.NewRouter(cfg) if err != nil { - log.Fatalf("Starting gateway failed: %s", err) + flog.Fatalf("Starting gateway failed: %s", err) } err = r.Start() if err != nil { - log.Fatalf("Starting gateway failed: %s", err) + flog.Fatalf("Starting gateway failed: %s", err) } - log.Printf("Gateway(s) started succesfully. Now relaying messages") + flog.Printf("Gateway(s) started succesfully. Now relaying messages") select {} } |