Documentation ¶
Index ¶
- Constants
- Variables
- func AddToLeft() slog.Attr
- func AddToRight() slog.Attr
- func PanicMsgToString(msg interface{}) string
- func StackTraceAttr(skipToFirstPanic bool, msg string) slog.Attr
- func WithLogLevel(lvl slog.Level) slog.Attr
- type AttrLevel
- type AttrOrder
- type ContextExtractor
- type ControlAttr
- type NopLogger
- type PinpointLogLevels
- func (p *PinpointLogLevels) FindLevel(stackFramesToSkip int) (slog.Level, bool)
- func (p *PinpointLogLevels) LevelForLocation(loc string) (slog.Level, bool)
- func (p *PinpointLogLevels) PrintConfig(c context.Context, l *slog.Logger)
- func (p *PinpointLogLevels) WithEnvironmentListOverrides(env []string) *PinpointLogLevels
- func (p *PinpointLogLevels) WithEnvironmentOverrides() *PinpointLogLevels
- func (p *PinpointLogLevels) WithOverride(l slog.Level, packagePrefixes ...string) *PinpointLogLevels
- type PrettySink
- type SinkingLogger
- type SlogConvenience
- type SlogOptions
- type StackElement
- type StackValue
Constants ¶
const StackAttrName = "stack"
const TIDBITS_ENV_PREFIX = "TIDBITS_LOG_"
Variables ¶
var BlackBackground = "\033[40m"
var BlueBackground = "\033[44m"
var ColorBlue = "\033[34m"
var ColorCyan = "\033[36m"
var ColorGray = "\033[37m"
var ColorGreen = "\033[32m"
var ColorRed = "\033[31m"
var ColorReset = "\033[0m"
var ColorWhite = "\033[97m"
var ColorYellow = "\033[33m"
var CyanBackground = "\033[46m"
var GrayBackground = "\033[47m"
var GreenBackground = "\033[42m"
var Purple = "\033[35m"
var PurpleBackground = "\033[45m"
var RedBackground = "\033[41m"
var WhiteBackground = "\033[107m"
var YellowBackground = "\033[43m"
Functions ¶
func AddToRight ¶
func PanicMsgToString ¶
func PanicMsgToString(msg interface{}) string
Types ¶
type ContextExtractor ¶
type ControlAttr ¶
type NopLogger ¶
NopLogger This is a logger that does nothing, it's intended to be used in unit tests to suppress log messages.
func NewNopLogger ¶
type PinpointLogLevels ¶
type PinpointLogLevels struct {
// contains filtered or unexported fields
}
func NewPinpointLogLevels ¶
func NewPinpointLogLevels() *PinpointLogLevels
func (*PinpointLogLevels) FindLevel ¶
func (p *PinpointLogLevels) FindLevel(stackFramesToSkip int) (slog.Level, bool)
func (*PinpointLogLevels) LevelForLocation ¶
func (p *PinpointLogLevels) LevelForLocation(loc string) (slog.Level, bool)
func (*PinpointLogLevels) PrintConfig ¶
func (p *PinpointLogLevels) PrintConfig(c context.Context, l *slog.Logger)
func (*PinpointLogLevels) WithEnvironmentListOverrides ¶
func (p *PinpointLogLevels) WithEnvironmentListOverrides(env []string) *PinpointLogLevels
func (*PinpointLogLevels) WithEnvironmentOverrides ¶
func (p *PinpointLogLevels) WithEnvironmentOverrides() *PinpointLogLevels
func (*PinpointLogLevels) WithOverride ¶
func (p *PinpointLogLevels) WithOverride(l slog.Level, packagePrefixes ...string) *PinpointLogLevels
type PrettySink ¶
type PrettySink struct {
// contains filtered or unexported fields
}
func NewPrettySink ¶
func (*PrettySink) GetHandler ¶
func (p *PrettySink) GetHandler() *slog.JSONHandler
type SinkingLogger ¶
SinkingLogger This is a logger that writes messages to a memory buffer, it's intended to be used in unit tests to make sure that the log messages are expected. As a convenience feature to make it easier to match the messages, this logger also removes the timestamp from the log entries.
func NewJsonOrTextSinkingLogger ¶
func NewJsonOrTextSinkingLogger(lvl slog.Level, textMode bool) *SinkingLogger
func NewSinkingLogger ¶
func NewSinkingLogger(lvl slog.Level) *SinkingLogger
func (*SinkingLogger) Get ¶
func (s *SinkingLogger) Get() string
Get returns the accumulated log data and resets the buffer
type SlogConvenience ¶
type SlogConvenience struct {
// contains filtered or unexported fields
}
func NewSlogConvenience ¶
func NewSlogConvenience(opts SlogOptions, delegate slog.Handler) *SlogConvenience
type SlogOptions ¶
type SlogOptions struct { AppendNewAttrsRight bool Pinpointer *PinpointLogLevels LogLevel slog.Level Extractors []ContextExtractor }
type StackElement ¶
type StackValue ¶
type StackValue struct {
// contains filtered or unexported fields
}
func NewStackValue ¶
func NewStackValue(skipFrames int, skipToFirstPanic bool, msg any) *StackValue
func (*StackValue) JSONStack ¶
func (s *StackValue) JSONStack() []StackElement
JSONStack creates a nice stack trace, skipping all the deferred frames after the first panic() call. This method returns the list of structures that can be nicely reflected into JSON.
func (*StackValue) MarshalJSON ¶
func (s *StackValue) MarshalJSON() ([]byte, error)
func (*StackValue) MarshalText ¶
func (s *StackValue) MarshalText() (text []byte, err error)
MarshalText creates a nice stack trace, skipping all the deferred frames after the first panic() call. This method returns a human-readable multi-line string.