SimpleCloudNotifier/scnserver/init.go

35 lines
597 B
Go
Raw Normal View History

2022-12-20 13:55:09 +01:00
package server
2022-11-13 19:17:07 +01:00
import (
"github.com/gin-gonic/gin"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"os"
)
2022-12-20 13:55:09 +01:00
func Init(cfg Config) {
2022-11-13 19:17:07 +01:00
cw := zerolog.ConsoleWriter{
Out: os.Stdout,
TimeFormat: "2006-01-02 15:04:05 Z07:00",
}
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
multi := zerolog.MultiLevelWriter(cw)
logger := zerolog.New(multi).With().
Timestamp().
Caller().
Logger()
log.Logger = logger
if cfg.GinDebug {
gin.SetMode(gin.DebugMode)
} else {
gin.SetMode(gin.ReleaseMode)
}
zerolog.SetGlobalLevel(cfg.LogLevel)
2022-11-13 19:17:07 +01:00
log.Debug().Msg("Initialized")
}