aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-08-24 21:23:40 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-08-24 21:28:28 +0200
commit347bd1674bbf67ccb6209951a4bf8f2971715532 (patch)
treeb34495fe40d7cf6c0d08a5b9a6b977b3981f9496 /lib
parent2fed63ed0087df0c79f7f30f7f397611381bfccd (diff)
Redirect HTTP and Gin server logs into a file (xds-server-verbose.log).
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'lib')
-rw-r--r--lib/syncthing/st.go5
-rw-r--r--lib/webserver/server.go8
-rw-r--r--lib/xdsconfig/config.go8
3 files changed, 13 insertions, 8 deletions
diff --git a/lib/syncthing/st.go b/lib/syncthing/st.go
index 10210a4..b622970 100644
--- a/lib/syncthing/st.go
+++ b/lib/syncthing/st.go
@@ -317,7 +317,10 @@ func (s *SyncThing) Connect() error {
return fmt.Errorf("ERROR: cannot connect to Syncthing (null client)")
}
- s.client.SetLogger(s.log)
+ // Redirect HTTP log into a file
+ s.client.SetLogLevel(s.conf.Log.Level.String())
+ s.client.LoggerPrefix = "SYNCTHING: "
+ s.client.LoggerOut = s.conf.LogVerboseOut
s.MyID, err = s.IDGet()
if err != nil {
diff --git a/lib/webserver/server.go b/lib/webserver/server.go
index 5183208..8639b66 100644
--- a/lib/webserver/server.go
+++ b/lib/webserver/server.go
@@ -46,10 +46,10 @@ func New(cfg *xdsconfig.Config, mfolders *model.Folders, sdks *crosssdk.SDKs, lo
gin.SetMode(gin.ReleaseMode)
}
- // Redirect gin logs into logrus logger
- gin.DefaultWriter = logr.Out
- gin.DefaultErrorWriter = logr.Out
- log.SetOutput(logr.Out)
+ // Redirect gin logs into another logger (LogVerboseOut may be stderr or a file)
+ gin.DefaultWriter = cfg.LogVerboseOut
+ gin.DefaultErrorWriter = cfg.LogVerboseOut
+ log.SetOutput(cfg.LogVerboseOut)
// FIXME - fix pb about isTerminal=false when out is in VSC Debug Console
diff --git a/lib/xdsconfig/config.go b/lib/xdsconfig/config.go
index a3e5a7e..82ca97f 100644
--- a/lib/xdsconfig/config.go
+++ b/lib/xdsconfig/config.go
@@ -2,6 +2,7 @@ package xdsconfig
import (
"fmt"
+ "io"
"os"
"github.com/Sirupsen/logrus"
@@ -17,9 +18,10 @@ type Config struct {
Builder BuilderConfig `json:"builder"`
// Private (un-exported fields in REST GET /config route)
- Options Options `json:"-"`
- FileConf FileConfig `json:"-"`
- Log *logrus.Logger `json:"-"`
+ Options Options `json:"-"`
+ FileConf FileConfig `json:"-"`
+ Log *logrus.Logger `json:"-"`
+ LogVerboseOut io.Writer `json:"-"`
}
// Options set at the command line