dendrite/common: Move logrus configuration to common

This commit is contained in:
Robert Swain 2017-04-20 14:40:56 +02:00
parent db428174d2
commit 8010083026
3 changed files with 29 additions and 36 deletions

View file

@ -0,0 +1,25 @@
package common
import (
"os"
"path/filepath"
"github.com/Sirupsen/logrus"
"github.com/matrix-org/dugong"
)
// SetupLogging configures the logging format and destination(s).
func SetupLogging(logDir string) {
_ = os.Mkdir(logDir, os.ModePerm)
logrus.AddHook(dugong.NewFSHook(
filepath.Join(logDir, "info.log"),
filepath.Join(logDir, "warn.log"),
filepath.Join(logDir, "error.log"),
&logrus.TextFormatter{
TimestampFormat: "2006-01-02 15:04:05.000000",
DisableColors: true,
DisableTimestamp: false,
DisableSorting: false,
}, &dugong.DailyRotationSchedule{GZip: true},
))
}