aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-12-05 11:10:21 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-12-05 11:10:35 +0100
commit40d77d7b1d1b41bd1f2f5a00037d21858114e188 (patch)
tree513d16248a431d0b09fbf68685dacc4f2a2d46b6
parentdf1af33ecdd4295171c4efa116c62a03f39df881 (diff)
Improved Silly logging.
-rw-r--r--.vscode/settings.json2
-rw-r--r--lib/xdsserver/sessions.go6
-rw-r--r--lib/xdsserver/xdsserver.go11
3 files changed, 13 insertions, 6 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 5a12530..ac5a7b6 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -29,6 +29,6 @@
"inotify", "Inot", "pname", "pkill", "sdkid", "CLOUDSYNC", "xdsagent",
"gdbserver", "golib", "eows", "mfolders", "IFOLDER", "flds", "dflt",
"stconfig", "reflectme", "franciscocpg", "crosssdk", "urfave", "EXEPATH",
- "conv"
+ "conv", "Sillyf"
]
}
diff --git a/lib/xdsserver/sessions.go b/lib/xdsserver/sessions.go
index 61f2f26..f7ce846 100644
--- a/lib/xdsserver/sessions.go
+++ b/lib/xdsserver/sessions.go
@@ -217,10 +217,8 @@ func (s *Sessions) monitorSessMap() {
s.Log.Debugln("Stop monitorSessMap")
return
case <-time.After(sessionMonitorTime * time.Second):
- if s.LogLevelSilly {
- s.Log.Debugf("Sessions Map size: %d", len(s.sessMap))
- s.Log.Debugf("Sessions Map : %v", s.sessMap)
- }
+ s.LogSillyf("Sessions Map size: %d", len(s.sessMap))
+ s.LogSillyf("Sessions Map : %v", s.sessMap)
if len(s.sessMap) > maxSessions {
s.Log.Errorln("TOO MUCH sessions, cleanup old ones !")
diff --git a/lib/xdsserver/xdsserver.go b/lib/xdsserver/xdsserver.go
index 33efa26..5079553 100644
--- a/lib/xdsserver/xdsserver.go
+++ b/lib/xdsserver/xdsserver.go
@@ -43,6 +43,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
@@ -70,14 +71,22 @@ func NewXdsServer(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,
Cli: cliCtx,
Log: log,
- LogLevelSilly: (sillyLog && sillyVal == "1"),
+ LogLevelSilly: logSilly,
+ LogSillyf: sillyFunc,
Exit: make(chan os.Signal, 1),
}