Documentation
¶
Overview ¶
Package formatters provides functions to format log messages.
Index ¶
- func CapitalizedLevel(level slog.Level) string
- func Date(logFormatRFC3339 bool) func(time.Time) string
- func ExtraJSONContext(record AttrHolder) string
- func ExtraTextContext(record AttrHolder) string
- func ExtractShortPathFromFullPath(fullPath string) string
- func Frame(r slog.Record) runtime.Frame
- func GetLogDateFormat(logFormatRFC3339 bool) string
- func LevelToString(level slog.Level) string
- func Quote(message string) string
- func RelFile(frame runtime.Frame) string
- func ShortFilePath(frame runtime.Frame) string
- func ShortFunction(frame runtime.Frame) string
- func ShortLevel(level slog.Level) string
- func ShortestLevel(level slog.Level) string
- func ToSlogAttrs(context interface{}) []slog.Attr
- func UppercaseLevel(level slog.Level) string
- type AttrHolder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CapitalizedLevel ¶
CapitalizedLevel returns a capitalized string representation of the log level
See https://github.com/cihub/seelog/blob/f561c5e57575bb1e0a2167028b7339b3a8d16fb4/format.go#L318
func ExtraJSONContext ¶
func ExtraJSONContext(record AttrHolder) string
ExtraJSONContext creates a JSON string of the record's attributes.
func ExtraTextContext ¶
func ExtraTextContext(record AttrHolder) string
ExtraTextContext creates a text string of the record's attributes.
func ExtractShortPathFromFullPath ¶
ExtractShortPathFromFullPath extracts the short path from a full path.
It is exported to be used from pkg/util/log/setup, and can be unexported once seelog is removed.
func GetLogDateFormat ¶
GetLogDateFormat returns the date format to use for the log.
It is exported to be used from pkg/util/log/setup, and can be unexported once seelog is removed.
func LevelToString ¶
LevelToString converts a slog.Level to a string
func RelFile ¶
RelFile removes the working directory from the full path.
See https://github.com/cihub/seelog/blob/f561c5e57575bb1e0a2167028b7339b3a8d16fb4/common_context.go#L45-L48 and shortPath in https://github.com/cihub/seelog/blob/f561c5e57575bb1e0a2167028b7339b3a8d16fb4/common_context.go#L100-L106
func ShortFilePath ¶
ShortFilePath returns the short path of the file that the log message was emitted from.
func ShortFunction ¶
ShortFunction returns the short function name of the function that the log message was emitted from.
See https://github.com/cihub/seelog/blob/f561c5e57575bb1e0a2167028b7339b3a8d16fb4/format.go#L400
func ShortLevel ¶
ShortLevel converts a slog.Level to a short string
See https://github.com/cihub/seelog/blob/f561c5e57575bb1e0a2167028b7339b3a8d16fb4/format.go#L328
func ShortestLevel ¶
ShortestLevel returns a single character representation of the log level
https://github.com/cihub/seelog/blob/f561c5e57575bb1e0a2167028b7339b3a8d16fb4/format.go#L338
func ToSlogAttrs ¶
ToSlogAttrs converts an opaque context to a list of slog.Attr
The context is expected to be a slice of interface{}, containing an even number of elements, with keys being strings.
We can lift the restrictions and/or change the API later, but for now we want the exact same behavior as previously.
This is exported to allow using it with seelog and slog, once we stop using seelog this can be moved to the slog package.
func UppercaseLevel ¶
UppercaseLevel returns an uppercase string representation of the log level
See https://github.com/cihub/seelog/blob/f561c5e57575bb1e0a2167028b7339b3a8d16fb4/format.go#L365