X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=main.go;h=6089e74b7dd0e69b065770f82a108ebd5a42f2ee;hb=17ab6663d5522bf4db3e6cce70352f8ba4379e99;hp=8af553db02c3ec2ec0d6219479d6b269da3d64ab;hpb=8119c1641e88ee5020e380c08119f508c6e24222;p=src%2Fxds%2Fxds-server.git 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 {