Documentation
¶
Index ¶
- func CreateDebugLogger(logdir string, name string)
- func CreateDefaultLogger(logdir string, name string)
- func NewChannelHandler() slog.Handler
- func NewDispatchHandler(handlers ...slog.Handler) slog.Handler
- func NewFileHandler(path string, name string) slog.Handler
- func NewFileHandlerWithLevel(path string, name string, l slog.Level) slog.Handler
- func Subscribe(level slog.Level, chnl chan slog.Record) (key string)
- func Unsubscribe(key string)
- type ChannelHandler
- func (h *ChannelHandler) Enabled(_ context.Context, l slog.Level) bool
- func (h *ChannelHandler) Handle(ctx context.Context, r slog.Record) error
- func (h *ChannelHandler) Subscribe(key string, level slog.Level, chnl chan slog.Record)
- func (h *ChannelHandler) Unsubscribe(key string)
- func (h *ChannelHandler) WithAttrs(attrs []slog.Attr) slog.Handler
- func (h *ChannelHandler) WithGroup(name string) slog.Handler
- type DispatchHandler
- type FileHandler
- func (h *FileHandler) Enabled(_ context.Context, l slog.Level) bool
- func (h *FileHandler) GetDelimiter() byte
- func (h *FileHandler) Handle(ctx context.Context, r slog.Record) error
- func (h *FileHandler) SetDelimiter(d byte)
- func (h *FileHandler) WithAttrs(attrs []slog.Attr) slog.Handler
- func (h *FileHandler) WithGroup(name string) slog.Handler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateDebugLogger ¶
func CreateDefaultLogger ¶
func NewChannelHandler ¶
NewChannelHandler creates a new ChannelHandler struct and returns it.
func NewDispatchHandler ¶
NewDispatchHandler creates a new dispatchHandler.
func NewFileHandler ¶
NewFileHandler creates a new file handler
func NewFileHandlerWithLevel ¶
NewfileHandler creates a new file handler that only logs lines with a level equalt to or higher than the provided level.
func Subscribe ¶
Subscribe subscribes to log events. The key identifies the subscription and can be used to unsubscribe at a later stage.
func Unsubscribe ¶
func Unsubscribe(key string)
Unsubscribe from a log event by giving the subscription key.
Types ¶
type ChannelHandler ¶
type ChannelHandler struct {
// contains filtered or unexported fields
}
func (*ChannelHandler) Enabled ¶
Enabled checks if the channel handler is enabled for a given log level
func (*ChannelHandler) Subscribe ¶
Subscribe is used to subscribe to a channel. It takes a string key, a slog.Level level, and a channel of slog.Records as parameters.
func (*ChannelHandler) Unsubscribe ¶
func (h *ChannelHandler) Unsubscribe(key string)
Unsubscribe is used to unsubscribe a key from the channel handler
type DispatchHandler ¶
type DispatchHandler struct {
// contains filtered or unexported fields
}
DispatchHandler dispatches the incomming log record to the configured handlers.
func (*DispatchHandler) Enabled ¶
Enabled implements slog.Handler. As soon as one of the child handlers is enabled for the log level, true is returned; otherwise false.
type FileHandler ¶
type FileHandler struct {
// contains filtered or unexported fields
}
FileHandler writes log lines to a file on disk. It is a thread-safe impelmentation.
func (*FileHandler) GetDelimiter ¶
func (h *FileHandler) GetDelimiter() byte
GetDelimiter returns the delimiter used in the log file. Default delimiter = ';'
func (*FileHandler) SetDelimiter ¶
func (h *FileHandler) SetDelimiter(d byte)
SetDelimiter allows you to set the delimiter