Documentation ¶
Index ¶
- func NewHandlerSyncer(syncer zapcore.WriteSyncer, handler slog.Handler) slog.Handler
- func NewStdLog(base *slog.Logger, prefix string) *log.Logger
- func NewZap(log *slog.Logger) *zap.Logger
- func NewZapCore(log *slog.Logger) zapcore.Core
- func ToAttrs(data map[string]any) []slog.Attr
- func ToLeveler(level string) slog.Leveler
- type Config
- type ConsoleHandler
- type HandlerOptions
- type HandlerSyncer
- type StdLogAdapter
- type ZapCore
- func (c *ZapCore) Check(ent zapcore.Entry, ce *zapcore.CheckedEntry) *zapcore.CheckedEntry
- func (c *ZapCore) Enabled(lvl zapcore.Level) bool
- func (c *ZapCore) Sync() error
- func (c *ZapCore) With(fields []zapcore.Field) zapcore.Core
- func (c *ZapCore) Write(ent zapcore.Entry, fields []zapcore.Field) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHandlerSyncer ¶
Types ¶
type Config ¶
type Config struct { // When AddSource is true, the handler adds a ("source", "file:line") // attribute to the output indicating the source code position of the log // statement. AddSource is false by default to skip the cost of computing // this information. AddSource bool `cfg:"add_source" mapstructure:"add_source" json:"add_source,omitempty" yaml:"add_source,omitempty"` // Level is the minimum enabled logging level. Level string `cfg:"level" mapstructure:"level" json:"level,omitempty" yaml:"level,omitempty"` // Encoding sets the logger's encoding. Init values are "json", "text" and "console" Encoding string `cfg:"encoding" mapstructure:"encoding" json:"encoding,omitempty" yaml:"encoding,omitempty"` // Output is a list of URLs or file paths to write logging output to. // See zap.Open for details. OutputPaths []string `cfg:"output_paths" mapstructure:"output_paths" json:"output_paths,omitempty" yaml:"output_paths,omitempty"` Attributes map[string]any `cfg:"attributes" mapstructure:"attributes" json:"attributes,omitempty" yaml:"attributes,omitempty"` }
func (*Config) Opts ¶
func (cfg *Config) Opts() *HandlerOptions
type ConsoleHandler ¶
type ConsoleHandler struct {
// contains filtered or unexported fields
}
func NewConsoleHandler ¶
func NewConsoleHandler(w io.Writer, opts *slog.HandlerOptions, attrs ...slog.Attr) *ConsoleHandler
type HandlerOptions ¶
type HandlerOptions struct {
*slog.HandlerOptions
}
func (HandlerOptions) NewHandler ¶
type HandlerSyncer ¶
type HandlerSyncer interface {
Sync() error
}
type StdLogAdapter ¶
type StdLogAdapter struct {
// contains filtered or unexported fields
}
StdLogAdapter can be passed to the http.Server or any place which required standard logger to redirect output to the logger plugin
func NewStdAdapter ¶
func NewStdAdapter(log *slog.Logger) *StdLogAdapter
NewStdAdapter constructs StdLogAdapter
Click to show internal directories.
Click to hide internal directories.