Skip to content

Commit 66965a5

Browse files
authored
(MAINT) Allow consumer to bring their own logging. (#72)
1 parent 5dc5c6d commit 66965a5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pkg/service/service.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const (
3131
// Config will hold the configuration of the service.
3232
type Config struct {
3333
ListenAddress string // Address in the format [host/ip]:port. Mandatory.
34+
DisableLog bool // Turn off service logging. Default is false.
3435
LogLevel string // INFO,FATAL,ERROR,WARN, DEBUG, TRACE.
3536
Cors *CorsConfig // Optional cors config.
3637
ReadinessCheck bool // Set to true to add a readiness handler at /readiness.
@@ -251,8 +252,11 @@ func NewService(cfg *Config) (*Service, error) {
251252

252253
gin.SetMode(gin.ReleaseMode)
253254
router := gin.New()
254-
logger := log.CreateLogger(cfg.LogLevel)
255-
router.Use(ginlogrus.Logger(logger, cfg.LogIgnorePaths...))
255+
256+
if !cfg.DisableLog {
257+
logger := log.CreateLogger(cfg.LogLevel)
258+
router.Use(ginlogrus.Logger(logger, cfg.LogIgnorePaths...))
259+
}
256260

257261
// Set CORS to the default if it's enabled and no override passed in.
258262
setupCors(router, cfg.Cors)

0 commit comments

Comments
 (0)