2022-05-20 11:31:39 +02:00
|
|
|
package event
|
|
|
|
|
|
|
|
import (
|
2022-12-23 01:35:59 +01:00
|
|
|
"log"
|
2022-05-20 11:31:39 +02:00
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/sirupsen/logrus"
|
2022-09-28 09:01:17 +02:00
|
|
|
|
|
|
|
"github.com/photoprism/photoprism/pkg/dummy"
|
2022-05-20 11:31:39 +02:00
|
|
|
)
|
|
|
|
|
2022-09-28 09:01:17 +02:00
|
|
|
// init initializes the event package.
|
2022-05-20 11:31:39 +02:00
|
|
|
func init() {
|
2022-09-28 09:01:17 +02:00
|
|
|
// Event hooks for the default logger.
|
2022-05-20 11:31:39 +02:00
|
|
|
hooks := logrus.LevelHooks{}
|
|
|
|
hooks.Add(NewHook(SharedHub()))
|
|
|
|
|
2022-09-28 09:01:17 +02:00
|
|
|
// Log is the global default logger.
|
2022-05-20 11:31:39 +02:00
|
|
|
Log = &logrus.Logger{
|
|
|
|
Out: os.Stderr,
|
2022-09-28 09:01:17 +02:00
|
|
|
Formatter: TextFormatter,
|
2022-05-20 11:31:39 +02:00
|
|
|
Hooks: hooks,
|
|
|
|
Level: logrus.DebugLevel,
|
|
|
|
ExitFunc: os.Exit,
|
|
|
|
ReportCaller: false,
|
|
|
|
}
|
2022-09-28 09:01:17 +02:00
|
|
|
|
2022-12-23 01:35:59 +01:00
|
|
|
// Default logger shall use Logrus.
|
|
|
|
log.SetFlags(0)
|
|
|
|
log.SetOutput(&LogWriter{
|
|
|
|
Log: Log,
|
|
|
|
Level: logrus.DebugLevel,
|
|
|
|
})
|
|
|
|
|
2022-09-28 09:01:17 +02:00
|
|
|
// Create dummy audit logger.
|
|
|
|
AuditLog = dummy.NewLogger()
|
2022-05-20 11:31:39 +02:00
|
|
|
}
|