Documentation ¶
Overview ¶
Package logging for dealing with logging, log settings and log format
Package logging for dealing with logging, log settings and log format
Inspiration: https://github.com/golang/example/tree/master/slog-handler-guide https://dusted.codes/creating-a-pretty-console-logger-using-gos-slog-package
Index ¶
Constants ¶
const ThisShouldNotHappenMessage = "this should not happen, please open an issue in issue tracker at https://github.com/9elements/firmware-action/issues"
ThisShouldNotHappenMessage contains a string which should be used in error message where the error justifies opening an issue in issue tracker
Variables ¶
This section is empty.
Functions ¶
func InitLogger ¶
func InitLogger(level slog.Level, opts ...PrettyHandlerOption)
InitLogger is used to initialize logger
func TrimNameFunction ¶
TrimNameFunction just trims the name
Types ¶
type PrettyHandler ¶
type PrettyHandler struct {
// contains filtered or unexported fields
}
PrettyHandler is for prettier logs
func NewPrettyHandler ¶
func NewPrettyHandler(output io.Writer, opts ...PrettyHandlerOption) *PrettyHandler
NewPrettyHandler returns a PrettyHandler
func (*PrettyHandler) Enabled ¶
Enabled reports whether the handler handles records at the given level
type PrettyHandlerOption ¶
type PrettyHandlerOption func(*PrettyHandler)
PrettyHandlerOption is for functional option pattern
func WithIndent ¶
func WithIndent(indent bool) PrettyHandlerOption
WithIndent enables or disables indentation (handy for programmatic processing out stderr)
func WithJSON ¶
func WithJSON(json bool) PrettyHandlerOption
WithJSON enables or disables JSON output (handy for programmatic processing out stderr)
func WithSkipFrames ¶
func WithSkipFrames(frames int) PrettyHandlerOption
WithSkipFrames changes how many stack frames to ascend in runtime.Caller()
0 = logging.(*PrettyHandler).Handle 1 = slog.(*Logger).log 2 = slog.Debug || slog.Info || slog.Warn || slog.Error 3 = place where we call slog.<LEVEL>