Skip to content

Commit 21257a1

Browse files
committed
Control log level
1 parent 6aa7f6c commit 21257a1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cmd/main.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
chimiddleware "github.com/go-chi/chi/v5/middleware"
1313
"github.com/labstack/echo/v4"
1414
"github.com/labstack/echo/v4/middleware"
15+
"github.com/labstack/gommon/log"
1516

1617
"gitlab.unjx.de/flohoss/gocron/config"
1718
"gitlab.unjx.de/flohoss/gocron/handlers"
@@ -35,7 +36,6 @@ func setupRouter() *echo.Echo {
3536
e.HideBanner = true
3637
e.HidePort = true
3738

38-
e.Use(middleware.Logger())
3939
e.Use(middleware.Recover())
4040
e.Use(middleware.CORS())
4141
e.Use(middleware.GzipWithConfig(middleware.GzipConfig{
@@ -57,6 +57,12 @@ func main() {
5757
}
5858

5959
e.Logger.SetLevel(env.GetLogLevel())
60+
if env.GetLogLevel() <= log.INFO {
61+
e.Use(middleware.Logger())
62+
}
63+
if env.GetLogLevel() == log.DEBUG {
64+
e.Debug = true
65+
}
6066

6167
cfg, err := config.New(configFolder + "config.yml")
6268
if err != nil {

0 commit comments

Comments
 (0)