"args": ["-log", "debug", "-c", "config.json.in"],
"showLog": false
},
-{
+ {
"name": "XDS-Server local dev",
"type": "go",
"request": "launch",
},
"args": ["-log", "debug", "-c", "__config_local_dev.json"],
"showLog": false
- },
- {
- "name": "XDS-Server IN DOCKER",
- "type": "go",
- "request": "launch",
- "mode": "debug",
- "port": 22000,
- "host": "172.17.0.2",
- "remotePath": "/xds/src/github.com/iotbzh/xds-server/bin/xds-server",
- "program": "${workspaceRoot}",
- "env": {
- "GOPATH": "${workspaceRoot}/../../../..:${env:GOPATH}",
- "ROOT_DIR": "${workspaceRoot}/../../../.."
- },
- "args": [],
- "showLog": true
}
-
]
}
- package: github.com/satori/go.uuid
version: ^1.1.0
- package: github.com/iotbzh/xds-common
- version: 363bac39b844
+ version: 4b8e35b6786b
subpackages:
- golib/common
- golib/eows
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 {
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
import (
"fmt"
+ "io"
"os"
"github.com/Sirupsen/logrus"
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
// Logs redirected into a file when logsDir is set
logfilename := cliCtx.GlobalString("logfile")
- if ctx.Config.FileConf.LogsDir != "" && logfilename != "stdout" {
- if logfilename == "" {
- logfilename = "xds-server.log"
- }
- // is it an absolute path ?
- logFile := logfilename
- if logfilename[0] == '.' || logfilename[0] != '/' {
- logFile = filepath.Join(ctx.Config.FileConf.LogsDir, logfilename)
+ ctx.Config.LogVerboseOut = os.Stderr
+ if ctx.Config.FileConf.LogsDir != "" {
+ if logfilename != "stdout" {
+ if logfilename == "" {
+ logfilename = "xds-server.log"
+ }
+ // is it an absolute path ?
+ logFile := logfilename
+ if logfilename[0] == '.' || logfilename[0] != '/' {
+ logFile = filepath.Join(ctx.Config.FileConf.LogsDir, logfilename)
+ }
+ fmt.Printf("Logging file: %s\n", logFile)
+ fdL, err := os.OpenFile(logFile, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)
+ if err != nil {
+ msgErr := fmt.Sprintf("Cannot create log file %s", logFile)
+ return cli.NewExitError(msgErr, int(syscall.EPERM))
+ }
+ ctx.Log.Out = fdL
}
- fmt.Printf("Logging file: %s\n", logFile)
- fdL, err := os.OpenFile(logFile, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)
+
+ logFileHTTPReq := filepath.Join(ctx.Config.FileConf.LogsDir, "xds-server-verbose.log")
+ fmt.Printf("Logging file for HTTP requests: %s\n", logFileHTTPReq)
+ fdLH, err := os.OpenFile(logFileHTTPReq, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)
if err != nil {
- msgErr := fmt.Sprintf("Cannot create log file %s", logFile)
+ msgErr := fmt.Sprintf("Cannot create log file %s", logFileHTTPReq)
return cli.NewExitError(msgErr, int(syscall.EPERM))
}
- ctx.Log.Out = fdL
+ ctx.Config.LogVerboseOut = fdLH
}
// Create syncthing instance when section "syncthing" is present in config.json