Help us shape the future of Go! Take the 2026 Go Developer Survey

agdcslog

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package agdcslog contains slog handler implementation that writes to system log.

Index

Constants

View Source
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"
)
View Source
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

func (h *SyslogHandler) Enabled(_ context.Context, level slog.Level) (enabled bool)

Enabled implements the slog.Handler interface for *SyslogHandler.

func (*SyslogHandler) Handle

func (h *SyslogHandler) Handle(ctx context.Context, rec slog.Record) (err error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL