Documentation ¶
Overview ¶
Package gripslog provides an interface shim between the "grip" logging package and the "slog" package.
Index ¶
- func ConvertLevel(l slog.Level) level.Priority
- func ConvertMessage(msg message.Composer) (string, slog.Map)
- func ConvertPriority(p level.Priority) slog.Level
- func ConvertSinkEntry(ent slog.SinkEntry) message.Composer
- func ConvertToSinkEntry(msg message.Composer) slog.SinkEntry
- func MakeSinkEntry(p level.Priority, msg interface{}) slog.SinkEntry
- func MakeSinkEntryWithLevel(p level.Priority, msg interface{}) slog.SinkEntry
- func NewSenderSink(s send.Sender) slog.Sink
- func NewSinkJournal(sink slog.Sink) grip.Journaler
- func NewSinkSender(name string, sink slog.Sink) send.Sender
- func NewSinkSenderWithContext(ctx context.Context, name string, sink slog.Sink) send.Sender
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertLevel ¶
ConvertLevel produces converts a slog.Level into the analogous grip priority.
func ConvertMessage ¶
ConvertMessage turns a grip message object into the kind of message+structured format that slog expects.
func ConvertPriority ¶
ConvertPriority converts a grip message's priority to a slog level. Invalid priorities become "info".
func ConvertSinkEntry ¶
ConvertSinkEntry turns a slog.SinkEntry into a message.Composer. The conversion is best-effort, and omits stack tracing data. Additionally the ordered nature of slog.SinkEntry is not preserved.
func ConvertToSinkEntry ¶
ConvertToSinkEntry provides a convenience wrapper around ConvertMessage to produce lower-level slog.SinkEntry payloads. This function does not populate stack info or other data.
func MakeSinkEntry ¶
MakeSinkEntry takes an arbitrary value, and coerces it to a slog.SinkEntry using the message.ConvertToComposer function that grip loggers use.
This operation will always override the priority of the resulting message, even when its already set to some other value
func MakeSinkEntryWithLevel ¶
MakeSinkEntryWithLevel takes an arbitrary value, and coerces it to a slog.SinkEntry using the message.ConvertToComposer function that grip loggers use.
This operation will use the existing value of the message's priority if set, and override it only if needed.
func NewSenderSink ¶
NewSenderSink wraps a send.Sender in a form that is usable as a slog.Sink.
func NewSinkJournal ¶
NewSinkJournal produces an independent grip.Journal instance that wraps a slog.Sink.
func NewSinkSender ¶
NewSinkSenderWithContext produces a send.Sender with the same semantics, as NewSinkSenderWithContext but does not require a context.
func NewSinkSenderWithContext ¶
NewSinkSenderWithContext produces a send.Sender that wraps the anaogous slog object, a slog.Sink.
Calls to SetName on this send.Sender instance will not impact the name of the slog.Logger or its hierarchy, and the level thresholds are tracked independently. Additionally, the sender's MessageFormater or ErrorHandler are not used.
The context is used when sending messages with slog, and is stored otherwise.
Types ¶
This section is empty.