mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-15 13:42:26 +03:00
dendrite/common: Move logrus configuration to common
This commit is contained in:
parent
db428174d2
commit
8010083026
3 changed files with 29 additions and 36 deletions
25
src/github.com/matrix-org/dendrite/common/log.go
Normal file
25
src/github.com/matrix-org/dendrite/common/log.go
Normal 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},
|
||||
))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue