diff options
author | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-08-08 16:59:56 +0200 |
---|---|---|
committer | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-08-08 16:59:56 +0200 |
commit | 0262f5bef6ff67e77b844a04733c57740fba9f00 (patch) | |
tree | f361629308a116094f4b4c1901c501e82d454cb8 /lib/webserver/server.go | |
parent | ae723466f745347c931a8a8bd9ff6dbf5237ece3 (diff) |
Added -logfile option.
Diffstat (limited to 'lib/webserver/server.go')
-rw-r--r-- | lib/webserver/server.go | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/webserver/server.go b/lib/webserver/server.go index 8fd7e44..7649cce 100644 --- a/lib/webserver/server.go +++ b/lib/webserver/server.go @@ -2,6 +2,7 @@ package webserver import ( "fmt" + "log" "net/http" "os" @@ -36,20 +37,21 @@ const indexFilename = "index.html" const cookieMaxAge = "3600" // New creates an instance of Server -func New(cfg *xdsconfig.Config, mfolder *model.Folder, sdks *crosssdk.SDKs, log *logrus.Logger) *Server { +func New(cfg *xdsconfig.Config, mfolder *model.Folder, sdks *crosssdk.SDKs, logr *logrus.Logger) *Server { // Setup logging for gin router - if log.Level == logrus.DebugLevel { + if logr.Level == logrus.DebugLevel { gin.SetMode(gin.DebugMode) } else { gin.SetMode(gin.ReleaseMode) } - // TODO - // - try to bind gin DefaultWriter & DefaultErrorWriter to logrus logger - // - try to fix pb about isTerminal=false when out is in VSC Debug Console - //gin.DefaultWriter = ?? - //gin.DefaultErrorWriter = ?? + // Redirect gin logs into logrus logger + gin.DefaultWriter = logr.Out + gin.DefaultErrorWriter = logr.Out + log.SetOutput(logr.Out) + + // FIXME - fix pb about isTerminal=false when out is in VSC Debug Console // Creates gin router r := gin.New() @@ -63,7 +65,7 @@ func New(cfg *xdsconfig.Config, mfolder *model.Folder, sdks *crosssdk.SDKs, log sessions: nil, mfolder: mfolder, sdks: sdks, - log: log, + log: logr, stop: make(chan struct{}), } |