diff options
author | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-12-05 10:52:24 +0100 |
---|---|---|
committer | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-12-05 10:52:24 +0100 |
commit | f75d24ca885690289c16adeac0e5c5e7bb56e36c (patch) | |
tree | b7d66cd4cffed7d0c1070312bebe92209575419f /lib/agent/agent.go | |
parent | 9194f6c934ab3af0a559290b9299f6be2d9b2269 (diff) |
Improved silly logging.
Diffstat (limited to 'lib/agent/agent.go')
-rw-r--r-- | lib/agent/agent.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/agent/agent.go b/lib/agent/agent.go index d1a3d05..58a2ba0 100644 --- a/lib/agent/agent.go +++ b/lib/agent/agent.go @@ -41,6 +41,7 @@ type Context struct { Config *xdsconfig.Config Log *logrus.Logger LogLevelSilly bool + LogSillyf func(format string, args ...interface{}) SThg *st.SyncThing SThgCmd *exec.Cmd SThgInotCmd *exec.Cmd @@ -71,13 +72,21 @@ func NewAgent(cliCtx *cli.Context) *Context { } log.Formatter = &logrus.TextFormatter{} + // Support silly logging (printed on log.debug) sillyVal, sillyLog := os.LookupEnv("XDS_LOG_SILLY") + logSilly := sillyLog && sillyVal == "1" + sillyFunc := func(format string, args ...interface{}) { + if logSilly { + log.Debugf("SILLY: "+format, args...) + } + } // Define default configuration ctx := Context{ ProgName: cliCtx.App.Name, Log: log, - LogLevelSilly: (sillyLog && sillyVal == "1"), + LogLevelSilly: logSilly, + LogSillyf: sillyFunc, Exit: make(chan os.Signal, 1), webServer: nil, |