Skip to content

Commit

Permalink
set custom time field
Browse files Browse the repository at this point in the history
  • Loading branch information
mluffman committed Oct 3, 2023
1 parent c8ad620 commit 8d2eff2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"context"
"fmt"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"log"
"net/http"
"os"
Expand All @@ -32,7 +33,10 @@ func main() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

logger, err := zap.NewProduction()
loggerConfig := zap.NewProductionConfig()
loggerConfig.EncoderConfig.TimeKey = "time"
loggerConfig.EncoderConfig.EncodeTime = zapcore.RFC3339TimeEncoder
logger, err := loggerConfig.Build()
if err != nil {
log.Fatalf("failed to initialize zap logger: %v", err)
}
Expand Down

0 comments on commit 8d2eff2

Please sign in to comment.