Enabled opens and close a socket connection by reusing or initializing
a global connection.
I also updated go-systemd to the current development release to include
the following fix:
75f33b08db
This is the only journal related change since the latest stable release
* fix casing
* remove redundant type conversions
* remove unnecessary append
x = append(y) is equivalent to x = y
* fix grammar and spelling
* rename file to enforce consistent casing with other READMEs in this repo
If a user is trying to fetch a logger from their context, they probably
want to log something. In order to allow returning a useable logger from Ctx()
without breaking backwards compatibilty with the previous behavior, we make it
configurable.
Added a package level variable "InterfaceMarshalFunc".
It's used to marshal interface to JSON encoded byte slice,
mostly when event.Interface("key", v) is called.
This adds the Func log method to log using an anonymous function
only if the level is currently enabled.
The use case is for when you don't own an object and therefore can't
create your own marshaller but need to do some translation prior to
logging.
For example, this:
msg := log.Debug()
if msg.Enabled() {
msg.Str("complicated_thing", makeBinaryThingLoggable(thing))
}
msg.Msg("Sending complicated thing")
Turns into this:
log.Debug().
Func(func(e *Event) { e.Str("complicated_thing", makeBinaryThingLoggable(thing)) }).
Msg("Sending complicated thing")
* Add event.CallerSkipFrame(skip int)
This indicates that, for this event, we should skip an additional
specified number of frames.
This is cumulative, calling it twice for the same event will add both
numbers together, and this is in addition to any skip frame settings set
through the context, or globally.
The indended purpose is for wrappers to Msg or Msgf, so that the actual
caller is always printed correctly.
* Use CallerSkipFrame for Print, Printf, and Write.
This allows us to use the correct caller when using these 3 functions.
Co-authored-by: Zephaniah E. Loss-Cutler-Hull <warp@aehallh.com>
Without this hlog.AccessHnalder reports a size written of 0 when the
ReadFrom method is used. This is easily visible when using
http.FileServer where all files are served with a logged size of 0.