diff options
author | z3bra <contact@z3bra.org> | 2020-07-18 15:46:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-18 15:46:19 +0200 |
commit | 213bf349c319811c8cb5458ac24ad9e61c5bbe4d (patch) | |
tree | 5e99075a45f456da330fba602f25b610a17a0d6b /matterbridge.go | |
parent | a94fe558868c39282530284110b059bd02e67a2d (diff) | |
download | matterbridge-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 'matterbridge.go')
-rw-r--r-- | matterbridge.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/matterbridge.go b/matterbridge.go index 7b04182d..63fd12f7 100644 --- a/matterbridge.go +++ b/matterbridge.go @@ -51,6 +51,15 @@ func main() { cfg := config.NewConfig(rootLogger, *flagConfig) cfg.BridgeValues().General.Debug = *flagDebug + // if logging to a file, ensure it is closed when the program terminates + // nolint:errcheck + defer func() { + if f, ok := rootLogger.Out.(*os.File); ok { + f.Sync() + f.Close() + } + }() + r, err := gateway.NewRouter(rootLogger, cfg, bridgemap.FullMap) if err != nil { logger.Fatalf("Starting gateway failed: %s", err) |