2022-09-04 03:27:02 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
2022-10-30 04:05:38 +00:00
|
|
|
"github.com/hay-kot/homebox/backend/internal/sys/config"
|
2022-09-04 03:27:02 +00:00
|
|
|
"github.com/rs/zerolog"
|
|
|
|
"github.com/rs/zerolog/log"
|
|
|
|
)
|
|
|
|
|
|
|
|
// setupLogger initializes the zerolog config
|
|
|
|
// for the shared logger.
|
|
|
|
func (a *app) setupLogger() {
|
|
|
|
// Logger Init
|
|
|
|
// zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
|
2022-09-14 17:35:23 +00:00
|
|
|
if a.conf.Log.Format != config.LogFormatJSON {
|
2022-10-30 02:15:35 +00:00
|
|
|
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}).With().Caller().Logger()
|
2022-09-04 03:27:02 +00:00
|
|
|
}
|
|
|
|
|
2024-01-28 03:28:43 +00:00
|
|
|
level, err := zerolog.ParseLevel(a.conf.Log.Level)
|
|
|
|
if err == nil {
|
|
|
|
zerolog.SetGlobalLevel(level)
|
2022-09-04 03:27:02 +00:00
|
|
|
}
|
|
|
|
}
|