logwise

package module
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: MIT Imports: 9 Imported by: 0

README

LogWise

Installation

go get -u github.com/gowool/logwise/v2

License

Distributed under MIT License, please see license file within the code for more details.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Discard slog.Handler = discardHandler{}

Discard is a [Handler] which is always disabled and therefore logs nothing.

Functions

func ColoredLevelEncoder

func ColoredLevelEncoder(level zapcore.Level, enc zapcore.PrimitiveArrayEncoder)

ColoredLevelEncoder colorizes log levels.

func ColoredNameEncoder

func ColoredNameEncoder(s string, enc zapcore.PrimitiveArrayEncoder)

ColoredNameEncoder colorizes service names.

func NewSlog

func NewSlog(logger *zap.Logger) *slog.Logger

func NewZap

func NewZap(cfg Config) (*zap.Logger, error)

Types

type Config

type Config struct {
	// Mode configures logger based on some default template (development, production, off).
	Mode Mode `json:"mode" yaml:"mode"`

	// Level is the minimum enabled logging level. Note that this is a dynamic
	// level, so calling ChannelConfig.Level.SetLevel will atomically change the log
	// level of all loggers descended from this config.
	Level string `json:"level" yaml:"level"`

	// LineEnding line ending. Default: "\n" for the all modes except production
	LineEnding string `json:"line_ending" yaml:"line_ending"`

	// Encoding sets the logger's encoding. InitDefault values are "json" and
	// "console", as well as any third-party encodings registered via
	// RegisterEncoder.
	Encoding string `json:"encoding" yaml:"encoding"`

	// Output is a list of URLs or file paths to write logging output to.
	// See Open for details.
	Output []string `json:"output" yaml:"output"`

	// ErrorOutput is a list of URLs to write internal logger errors to.
	// The default is standard error.
	//
	// Note that this setting only affects internal errors; for sample code that
	// sends error-level logs to a different location from info- and debug-level
	// logs, see the package-level AdvancedConfiguration example.
	ErrorOutput []string `json:"error_output" yaml:"error_output"`

	// File logger options
	FileLogger *lumberjack.Logger `json:"file_logger,omitempty" yaml:"file_logger,omitempty"`
}

func (*Config) InitDefaults

func (cfg *Config) InitDefaults()

type Mode

type Mode string

Mode represents available logger modes

Jump to

Keyboard shortcuts

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