@@ -5,10 +5,16 @@ import (
55 "fmt"
66 "log/slog"
77 "math/rand"
8+ "os"
89 "strings"
910 "time"
1011
1112 "github.com/labstack/echo/v4"
13+ "github.com/labstack/gommon/log"
14+ )
15+
16+ var (
17+ env = os .Getenv ("ENV" )
1218)
1319
1420// ContextHandler is our base context handler, it will handle all requests
@@ -138,9 +144,37 @@ func Replacer(groups []string, a slog.Attr) slog.Attr {
138144}
139145
140146func Errorf (ctx context.Context , format string , args ... interface {}) {
147+ if env == "dev" {
148+ log .Errorf (format , args ... )
149+ return
150+ }
151+
141152 slog .ErrorContext (ctx , fmt .Sprintf (format , args ... ))
142153}
143154
144155func Infof (ctx context.Context , format string , args ... interface {}) {
156+ if env == "dev" {
157+ log .Infof (format , args ... )
158+ return
159+ }
160+
145161 slog .InfoContext (ctx , fmt .Sprintf (format , args ... ))
146162}
163+
164+ func Warnf (ctx context.Context , format string , args ... interface {}) {
165+ if env == "dev" {
166+ log .Warnf (format , args ... )
167+ return
168+ }
169+
170+ slog .WarnContext (ctx , fmt .Sprintf (format , args ... ))
171+ }
172+
173+ func Debugf (ctx context.Context , format string , args ... interface {}) {
174+ if env == "dev" {
175+ log .Debugf (format , args ... )
176+ return
177+ }
178+
179+ slog .DebugContext (ctx , fmt .Sprintf (format , args ... ))
180+ }
0 commit comments