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:
parent
7c8a430f49
commit
f9850c3264
2
main.go
2
main.go
@ -31,6 +31,7 @@ func main() {
|
|||||||
maxPhotoXArg := flag.Int("max-photo-width", 0, "Maximum width of photos. 0 means no limit.")
|
maxPhotoXArg := flag.Int("max-photo-width", 0, "Maximum width of photos. 0 means no limit.")
|
||||||
maxPhotoYArg := flag.Int("max-photo-height", 0, "Maximum height of photos. 0 means no limit.")
|
maxPhotoYArg := flag.Int("max-photo-height", 0, "Maximum height of photos. 0 means no limit.")
|
||||||
photoQualityArg := flag.Int("photo-quality", 90, "Photo JPEG quality.")
|
photoQualityArg := flag.Int("photo-quality", 90, "Photo JPEG quality.")
|
||||||
|
debug := flag.Bool("debug", false, "If specified, logging level will be set to debug instead of info.")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
@ -66,6 +67,7 @@ func main() {
|
|||||||
MaxPhotoX: *maxPhotoXArg,
|
MaxPhotoX: *maxPhotoXArg,
|
||||||
MaxPhotoY: *maxPhotoYArg,
|
MaxPhotoY: *maxPhotoYArg,
|
||||||
PhotoQuality: *photoQualityArg,
|
PhotoQuality: *photoQualityArg,
|
||||||
|
Debug: *debug,
|
||||||
})
|
})
|
||||||
|
|
||||||
sigs := make(chan os.Signal, 1)
|
sigs := make(chan os.Signal, 1)
|
||||||
|
@ -35,7 +35,6 @@ func (s *Server) setupRouter() *gin.Engine {
|
|||||||
router.Use(gin.Recovery())
|
router.Use(gin.Recovery())
|
||||||
|
|
||||||
// logging
|
// logging
|
||||||
ginLogger := logrus.New()
|
|
||||||
hostname, err := os.Hostname()
|
hostname, err := os.Hostname()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
hostname = "unknown"
|
hostname = "unknown"
|
||||||
@ -54,7 +53,7 @@ func (s *Server) setupRouter() *gin.Engine {
|
|||||||
if dataLength < 0 {
|
if dataLength < 0 {
|
||||||
dataLength = 0
|
dataLength = 0
|
||||||
}
|
}
|
||||||
entry := ginLogger.WithFields(logrus.Fields{
|
entry := s.log.WithFields(logrus.Fields{
|
||||||
"hostname": hostname,
|
"hostname": hostname,
|
||||||
"statusCode": statusCode,
|
"statusCode": statusCode,
|
||||||
"latency": latency,
|
"latency": latency,
|
||||||
|
@ -53,6 +53,7 @@ type ServerConfig struct {
|
|||||||
MaxPhotoX int
|
MaxPhotoX int
|
||||||
MaxPhotoY int
|
MaxPhotoY int
|
||||||
PhotoQuality int
|
PhotoQuality int
|
||||||
|
Debug bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(config ServerConfig) *Server {
|
func New(config ServerConfig) *Server {
|
||||||
@ -63,7 +64,9 @@ func New(config ServerConfig) *Server {
|
|||||||
|
|
||||||
func (s *Server) Run(ctx context.Context) {
|
func (s *Server) Run(ctx context.Context) {
|
||||||
s.log = logrus.New()
|
s.log = logrus.New()
|
||||||
|
if s.config.Debug {
|
||||||
s.log.SetLevel(logrus.DebugLevel)
|
s.log.SetLevel(logrus.DebugLevel)
|
||||||
|
}
|
||||||
|
|
||||||
s.ctx = ctx
|
s.ctx = ctx
|
||||||
s.setupDB()
|
s.setupDB()
|
||||||
|
Loading…
Reference in New Issue
Block a user