mirror of
https://github.com/Cernobor/oko-server.git
synced 2025-02-24 08:27:17 +00:00
Debug logging configuration.
* Accepts a -debug option which sets logging level to debug.
This commit is contained in:
+1
-2
@@ -35,7 +35,6 @@ func (s *Server) setupRouter() *gin.Engine {
|
||||
router.Use(gin.Recovery())
|
||||
|
||||
// logging
|
||||
ginLogger := logrus.New()
|
||||
hostname, err := os.Hostname()
|
||||
if err != nil {
|
||||
hostname = "unknown"
|
||||
@@ -54,7 +53,7 @@ func (s *Server) setupRouter() *gin.Engine {
|
||||
if dataLength < 0 {
|
||||
dataLength = 0
|
||||
}
|
||||
entry := ginLogger.WithFields(logrus.Fields{
|
||||
entry := s.log.WithFields(logrus.Fields{
|
||||
"hostname": hostname,
|
||||
"statusCode": statusCode,
|
||||
"latency": latency,
|
||||
|
||||
+4
-1
@@ -53,6 +53,7 @@ type ServerConfig struct {
|
||||
MaxPhotoX int
|
||||
MaxPhotoY int
|
||||
PhotoQuality int
|
||||
Debug bool
|
||||
}
|
||||
|
||||
func New(config ServerConfig) *Server {
|
||||
@@ -63,7 +64,9 @@ func New(config ServerConfig) *Server {
|
||||
|
||||
func (s *Server) Run(ctx context.Context) {
|
||||
s.log = logrus.New()
|
||||
s.log.SetLevel(logrus.DebugLevel)
|
||||
if s.config.Debug {
|
||||
s.log.SetLevel(logrus.DebugLevel)
|
||||
}
|
||||
|
||||
s.ctx = ctx
|
||||
s.setupDB()
|
||||
|
||||
Reference in New Issue
Block a user