photoprism/internal/event/init.go
Michael Mayer cab5efba36 Logging: Add output writer wrapper so the default logger can use Logrus
Signed-off-by: Michael Mayer <michael@photoprism.app>
2022-12-23 01:35:59 +01:00

37 lines
695 B
Go

package event
import (
"log"
"os"
"github.com/sirupsen/logrus"
"github.com/photoprism/photoprism/pkg/dummy"
)
// init initializes the event package.
func init() {
// Event hooks for the default logger.
hooks := logrus.LevelHooks{}
hooks.Add(NewHook(SharedHub()))
// Log is the global default logger.
Log = &logrus.Logger{
Out: os.Stderr,
Formatter: TextFormatter,
Hooks: hooks,
Level: logrus.DebugLevel,
ExitFunc: os.Exit,
ReportCaller: false,
}
// Default logger shall use Logrus.
log.SetFlags(0)
log.SetOutput(&LogWriter{
Log: Log,
Level: logrus.DebugLevel,
})
// Create dummy audit logger.
AuditLog = dummy.NewLogger()
}