aboutsummaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-10-16 17:54:11 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-11-06 15:57:04 +0100
commit17ab6663d5522bf4db3e6cce70352f8ba4379e99 (patch)
tree172403491a3c57a3da68447adb3e5dabf52a1d04 /main.go
parent8119c1641e88ee5020e380c08119f508c6e24222 (diff)
Add silly log level support.
Silly logging is enable when: XDS_LOG_SILLY env var is set and log level is debug
Diffstat (limited to 'main.go')
-rw-r--r--main.go36
1 files changed, 20 insertions, 16 deletions
diff --git a/main.go b/main.go
index 8af553d..6089e74 100644
--- a/main.go
+++ b/main.go
@@ -41,17 +41,18 @@ var AppSubVersion = "unknown-dev"
// Context holds the XDS server context
type Context struct {
- ProgName string
- Cli *cli.Context
- Config *xdsconfig.Config
- Log *logrus.Logger
- SThg *st.SyncThing
- SThgCmd *exec.Cmd
- SThgInotCmd *exec.Cmd
- MFolders *model.Folders
- SDKs *crosssdk.SDKs
- WWWServer *webserver.Server
- Exit chan os.Signal
+ ProgName string
+ Cli *cli.Context
+ Config *xdsconfig.Config
+ Log *logrus.Logger
+ LogLevelSilly bool
+ SThg *st.SyncThing
+ SThgCmd *exec.Cmd
+ SThgInotCmd *exec.Cmd
+ MFolders *model.Folders
+ SDKs *crosssdk.SDKs
+ WWWServer *webserver.Server
+ Exit chan os.Signal
}
// NewContext Create a new instance of XDS server
@@ -71,12 +72,15 @@ func NewContext(cliCtx *cli.Context) *Context {
}
log.Formatter = &logrus.TextFormatter{}
+ sillyVal, sillyLog := os.LookupEnv("XDS_LOG_SILLY")
+
// Define default configuration
ctx := Context{
- ProgName: cliCtx.App.Name,
- Cli: cliCtx,
- Log: log,
- Exit: make(chan os.Signal, 1),
+ ProgName: cliCtx.App.Name,
+ Cli: cliCtx,
+ Log: log,
+ LogLevelSilly: (sillyLog && sillyVal == "1"),
+ Exit: make(chan os.Signal, 1),
}
// register handler on SIGTERM / exit
@@ -212,7 +216,7 @@ func xdsApp(cliCtx *cli.Context) error {
}
// Create Web Server
- ctx.WWWServer = webserver.New(ctx.Config, ctx.MFolders, ctx.SDKs, ctx.Log)
+ ctx.WWWServer = webserver.New(ctx.Config, ctx.MFolders, ctx.SDKs, ctx.Log, ctx.LogLevelSilly)
// Run Web Server until exit requested (blocking call)
if err = ctx.WWWServer.Serve(); err != nil {