Skip to content

Commit

Permalink
feat: Update prod logger to log to file (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
kzalys authored Oct 24, 2020
1 parent 78fd976 commit 279e1a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ data
mocks
.idea
*vendor*
*.log
6 changes: 5 additions & 1 deletion utils/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ import (
"go.uber.org/zap"
)

const logFile = "app.log"

// NewLogger creates a new zap logger
func NewLogger() (*zap.Logger, error) {
if os.Getenv(environment.Environment) == "prod" {
return zap.NewProduction()
cfg := zap.NewProductionConfig()
cfg.OutputPaths = []string{logFile, os.Stdout.Name()}
return cfg.Build()
}
return zap.NewDevelopment()
}

0 comments on commit 279e1a8

Please sign in to comment.