-
Notifications
You must be signed in to change notification settings - Fork 604
Closed
Description
Code:
package main
import (
"fmt"
"os"
"time"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
)
func main() {
timeFormat := "2006-01-02 15:04:05"
t := time.Now()
fmt.Print("local zone: ")
fmt.Println(t.Local().Zone())
fmt.Println("def:", t.Format(timeFormat))
fmt.Println("loc:", t.Local().Format(timeFormat))
fmt.Println("utc:", t.UTC().Format(timeFormat))
zerolog.TimeFieldFormat = timeFormat
log.Print("hello world")
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr, TimeFormat: timeFormat})
log.Info().Msg("Wrong time")
}
Output:
local zone: CST 28800
def: 2022-09-23 21:19:29
loc: 2022-09-23 21:19:29
utc: 2022-09-23 13:19:29
{"level":"debug","time":"2022-09-23 21:19:29","message":"hello world"}
2022-09-24 05:19:29 INF Wrong time
The local time is 2022-09-23 21:19:29 and the UTC time is 2022-09-23 13:19:29, but the console output time is 2022-09-24 05:19:29 .
This issue is caused by #415 .
Metadata
Metadata
Assignees
Labels
No labels