You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
Thanks for this package, it seems quite close to what i need - a simple logger system for golang.
I just have one issue : default formatter outputs everything with wrong time, for example, on my system (french hour in UTC+2) :
16:25 sergio@solaris ~/% date
Sat Jul 24 04:25:47 PM CEST 2021
16:25 sergio@solaris ~/% make run
2021-07-24 14:26:02 INFO <myprogram>.go:174 <log from loggo>
(system time = 16:25pm, but loggo is display 14:26pm)
Edit : i know this can be overridden by changing formatter, but an option would be more out-of-the-box, instead of having to override DefaultFormatter
loggo.ReplaceDefaultWriter(loggo.NewSimpleWriter(os.Stderr, LocalLoggoFormatter))
(...)
func LocalLoggoFormatter(entry loggo.Entry) string {
ts := entry.Timestamp.In(time.Local).Format("2006-01-02 15:04:05")
// Just get the basename from the filename
filename := filepath.Base(entry.Filename)
return fmt.Sprintf("%s %s %s %s:%d %s", ts, entry.Level, entry.Module, filename, entry.Line, entry.Message)
}
The text was updated successfully, but these errors were encountered:
you should be able to change the default formatter by updating the default
writer.
You can see the default formatter here:
https://github.com/juju/loggo/blob/master/formatter.go
You could write the same thing but changing `Timestamp.In(time.UTC)` to
`Timestamp.In(time.Local)`.
And then your writer becomes:
localTimeWriter := loggo.NewSimpleWriter(os.Stderr, localTimeFormatter)
loggo.ReplaceDefaultWriter(localTimeWriter)
On Sat, Jul 24, 2021 at 10:27 AM Serge ***@***.***> wrote:
Hello,
Thanks for this package, it seems quite close to what i need - a simple
logger system for golang.
I just have one issue : default formatter outputs everything with wrong
time, for example, on my system (french hour in UTC+2) :
16:25 ***@***.*** ~/% date
Sat Jul 24 04:25:47 PM CEST 2021
16:25 ***@***.*** ~/% make run
2021-07-24 14:26:02 INFO <myprogram>.go:174 <log from loggo>
(system time = 16:25pm, but loggo is display 14:26pm)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#44>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABRQ7OGZ73DIXJGQRZ5HVTTZLEWPANCNFSM5A5Q25LQ>
.
Hello,
Thanks for this package, it seems quite close to what i need - a simple logger system for golang.
I just have one issue : default formatter outputs everything with wrong time, for example, on my system (french hour in UTC+2) :
(system time = 16:25pm, but loggo is display 14:26pm)
Edit : i know this can be overridden by changing formatter, but an option would be more out-of-the-box, instead of having to override DefaultFormatter
The text was updated successfully, but these errors were encountered: