summaryrefslogtreecommitdiffstats
path: root/bridge/config/config.go
diff options
context:
space:
mode:
authorz3bra <contact@z3bra.org>2020-07-18 15:46:19 +0200
committerGitHub <noreply@github.com>2020-07-18 15:46:19 +0200
commit213bf349c319811c8cb5458ac24ad9e61c5bbe4d (patch)
tree5e99075a45f456da330fba602f25b610a17a0d6b /bridge/config/config.go
parenta94fe558868c39282530284110b059bd02e67a2d (diff)
downloadmatterbridge-msglm-213bf349c319811c8cb5458ac24ad9e61c5bbe4d.tar.gz
matterbridge-msglm-213bf349c319811c8cb5458ac24ad9e61c5bbe4d.tar.bz2
matterbridge-msglm-213bf349c319811c8cb5458ac24ad9e61c5bbe4d.zip
Add an option to log into a file rather than stdout (#1168)
Use Logfile option in the `[general]` section
Diffstat (limited to 'bridge/config/config.go')
-rw-r--r--bridge/config/config.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/bridge/config/config.go b/bridge/config/config.go
index d98c9423..6e99066c 100644
--- a/bridge/config/config.go
+++ b/bridge/config/config.go
@@ -3,6 +3,7 @@ package config
import (
"bytes"
"io/ioutil"
+ "os"
"path/filepath"
"strings"
"sync"
@@ -93,6 +94,7 @@ type Protocol struct {
JoinDelay string // all protocols
Label string // all protocols
Login string // mattermost, matrix
+ LogFile string // general
MediaDownloadBlackList []string
MediaDownloadPath string // Basically MediaServerUpload, but instead of uploading it, just write it to a file on the same server.
MediaDownloadSize int // all protocols
@@ -247,6 +249,15 @@ func NewConfig(rootLogger *logrus.Logger, cfgfile string) Config {
cfgtype := detectConfigType(cfgfile)
mycfg := newConfigFromString(logger, input, cfgtype)
+ if mycfg.cv.General.LogFile != "" {
+ logfile, err := os.OpenFile(mycfg.cv.General.LogFile, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0600)
+ if err == nil {
+ logger.Info("Opening log file ", mycfg.cv.General.LogFile)
+ rootLogger.Out = logfile
+ } else {
+ logger.Warn("Failed to open ", mycfg.cv.General.LogFile)
+ }
+ }
if mycfg.cv.General.MediaDownloadSize == 0 {
mycfg.cv.General.MediaDownloadSize = 1000000
}