Skip to content

Commit 279e1a8

Browse files
authored
feat: Update prod logger to log to file (#146)
1 parent 78fd976 commit 279e1a8

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ data
66
mocks
77
.idea
88
*vendor*
9+
*.log

utils/logger.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ import (
77
"go.uber.org/zap"
88
)
99

10+
const logFile = "app.log"
11+
1012
// NewLogger creates a new zap logger
1113
func NewLogger() (*zap.Logger, error) {
1214
if os.Getenv(environment.Environment) == "prod" {
13-
return zap.NewProduction()
15+
cfg := zap.NewProductionConfig()
16+
cfg.OutputPaths = []string{logFile, os.Stdout.Name()}
17+
return cfg.Build()
1418
}
1519
return zap.NewDevelopment()
1620
}

0 commit comments

Comments
 (0)