Documentation
¶
Overview ¶
Package agdcslog contains slog handler implementation that writes to system log.
Index ¶
- Constants
- type SyslogHandler
- func (h *SyslogHandler) Close() (err error)
- func (h *SyslogHandler) Enabled(_ context.Context, level slog.Level) (enabled bool)
- func (h *SyslogHandler) Handle(ctx context.Context, rec slog.Record) (err error)
- func (h *SyslogHandler) WithAttrs(attrs []slog.Attr) (handler slog.Handler)
- func (h *SyslogHandler) WithGroup(name string) (handler slog.Handler)
- type SystemLogger
Constants ¶
const ( // KeyUpstreamType is the log attribute for the upstream types. See the // UpstreamType* constants below. KeyUpstreamType = "upstream_type" // KeyUpstreamGroup is the log attribute for the upstream groups. KeyUpstreamGroup = "upstream_group" )
const ( // UpstreamTypeBootstrap is the log attribute value for bootstrap upstreams. UpstreamTypeBootstrap = "bootstrap" // UpstreamTypeFallback is the log attribute value for fallback upstreams. UpstreamTypeFallback = "fallback" // UpstreamTypeMain is the log attribute value for main upstreams. UpstreamTypeMain = "main" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SyslogHandler ¶
type SyslogHandler struct {
// contains filtered or unexported fields
}
SyslogHandler is a slog.Handler that writes to system log.
func NewSyslogHandler ¶
func NewSyslogHandler(logger SystemLogger, opts *slog.HandlerOptions) (h *SyslogHandler)
NewSyslogHandler returns an initialized SyslogHandler that writes to system log. opts must not be nil and contain Level.
func (*SyslogHandler) Close ¶
func (h *SyslogHandler) Close() (err error)
Close closes an underlying system logger.
func (*SyslogHandler) Enabled ¶
Enabled implements the slog.Handler interface for *SyslogHandler.
func (*SyslogHandler) Handle ¶
Handle implements the slog.Handler interface for *SyslogHandler.
func (*SyslogHandler) WithAttrs ¶
func (h *SyslogHandler) WithAttrs(attrs []slog.Attr) (handler slog.Handler)
WithAttrs implements the slog.Handler interface for *SyslogHandler.
func (*SyslogHandler) WithGroup ¶
func (h *SyslogHandler) WithGroup(name string) (handler slog.Handler)
WithGroup implements the slog.Handler interface for *SyslogHandler.
type SystemLogger ¶
type SystemLogger interface {
// Debug logs a message at debug level.
Debug(msg string) (err error)
// Info logs a message at info level.
Info(msg string) (err error)
// Warning logs a message at warning level.
Warning(msg string) (err error)
// Error logs a message at error level.
Error(msg string) (err error)
// Close detaches from the system logger.
io.Closer
}
SystemLogger is a platform-specific system logger.
TODO(e.burkov): Consider moving to golibs.
TODO(s.chzhen): Add platform-specific integration tests.
func NewSystemLogger ¶
func NewSystemLogger(ctx context.Context, name string) (l SystemLogger, err error)
NewSystemLogger returns a platform-specific system logger. name is the name of service.