mirror of
https://github.com/Fishwaldo/huma.git
synced 2025-03-15 19:31:27 +00:00
Merge pull request #5 from danielgtaylor/lg/timestamps
feat: add iso8601 timestamps to logging
This commit is contained in:
commit
d7e3237de2
1 changed files with 7 additions and 0 deletions
|
@ -135,14 +135,21 @@ func NewLogger() (*zap.Logger, error) {
|
|||
config := zap.NewDevelopmentConfig()
|
||||
logLevel = &config.Level
|
||||
config.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
|
||||
config.EncoderConfig.EncodeTime = iso8601UTCTimeEncoder
|
||||
return config.Build()
|
||||
}
|
||||
|
||||
config := zap.NewProductionConfig()
|
||||
config.EncoderConfig.EncodeTime = iso8601UTCTimeEncoder
|
||||
logLevel = &config.Level
|
||||
return config.Build()
|
||||
}
|
||||
|
||||
// A UTC variation of ZapCore.ISO8601TimeEncoder with millisecond precision
|
||||
func iso8601UTCTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder) {
|
||||
enc.AppendString(t.UTC().Format("2006-01-02T15:04:05.000Z"))
|
||||
}
|
||||
|
||||
// LogOption is used to set optional configuration for logging.
|
||||
type LogOption func(*zap.Logger) *zap.Logger
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue