kataras / golog

A high-performant Logging Foundation for Go Applications. X3 faster than the rest leveled loggers.
BSD 3-Clause "New" or "Revised" License
329 stars 43 forks source link

JSONFormatter: Date instead of timestamp #30

Open TatuMon opened 5 months ago

TatuMon commented 5 months ago

Hello. As the title says, when I use the JSONFormatter, I want to be able to show the date instead of the unix timestamp. Is this possible?

I tried setting the log like this but it doesn't work:

golog.SetFormat("json").SetTimeFormat(time.RFC3339).Info("404 unknown route", golog.Fields{
    "endpoint": ctx.Request().URL.RequestURI(),
    "body": bodyMap,
})

I still get this log:

{
  "timestamp": 1718810294,
  "level": "info",
  "message": "404 unknown route",
  "fields": {
    "body": null,
    "endpoint": "/sds?sublime2"
  }
}