log

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoneLevel = iota
	// PanicLevel level, the highest level of severity. will call panic() if the logging level <= PanicLevel.
	PanicLevel
	// FatalLevel level. Logs and then calls `logger.Exit(1)`. It will exit even if the
	// logging level <= FatalLevel.
	FatalLevel
	// ErrorLevel level. Runtime errors. Used for errors that should definitely be noted.
	// Commonly used for hooks to send errors to an error tracking service.
	ErrorLevel
	// WarnLevel level. Non-critical entries that deserve eyes.
	WarnLevel
	// NoticeLevel level Uncommon events
	NoticeLevel
	// InfoLevel level. Examples: User logs in, SQL logs.
	InfoLevel
	// DebugLevel level. Usually only enabled when debugging. Very verbose logging.
	DebugLevel
	// TraceLevel level. Designates finer-grained informational events than the Debug.
	TraceLevel
)

Variables

View Source
var DefaultEmptyEntry = &EmptyEntry{}

Functions

func Close

func Close()

func Debugf

func Debugf(format string, v ...any)

func Errorf

func Errorf(format string, v ...any)

func Infof

func Infof(format string, v ...any)

func InitLogger

func InitLogger(appName string, o *Options)

func SetAsync

func SetAsync(async bool)

func SetConfig

func SetConfig(ops ...WithConfig)

func SetLevel

func SetLevel(level int)

func SetLogger

func SetLogger(nl Logger)

func Warnf

func Warnf(format string, v ...any)

Types

type EmptyEntry

type EmptyEntry struct{}

func (*EmptyEntry) Log

func (l *EmptyEntry) Log()

func (*EmptyEntry) WithField

func (l *EmptyEntry) WithField(any, FieldCall) Entry

func (*EmptyEntry) WithFields

func (l *EmptyEntry) WithFields(Fields) Entry

func (*EmptyEntry) WithFormat

func (l *EmptyEntry) WithFormat(string) Entry

func (*EmptyEntry) WithLevel

func (l *EmptyEntry) WithLevel(int) Entry

func (*EmptyEntry) WithTime

func (l *EmptyEntry) WithTime(time.Time) Entry

type EmptyLogger

type EmptyLogger struct{}

func (*EmptyLogger) Debugf

func (l *EmptyLogger) Debugf(string, ...any)

func (*EmptyLogger) Errorf

func (l *EmptyLogger) Errorf(string, ...any)

func (*EmptyLogger) Infof

func (l *EmptyLogger) Infof(string, ...any)

func (*EmptyLogger) SetLevel

func (l *EmptyLogger) SetLevel(int)

func (*EmptyLogger) Warnf

func (l *EmptyLogger) Warnf(string, ...any)

func (*EmptyLogger) WithDebug

func (l *EmptyLogger) WithDebug(string) Entry

func (*EmptyLogger) WithError

func (l *EmptyLogger) WithError(string) Entry

func (*EmptyLogger) WithInfo

func (l *EmptyLogger) WithInfo(string) Entry

func (*EmptyLogger) WithWarn

func (l *EmptyLogger) WithWarn(string) Entry

type Entry

type Entry interface {
	WithLevel(level int) Entry
	WithTime(t time.Time) Entry
	WithFormat(f string) Entry
	WithField(v any, call FieldCall) Entry
	WithFields(Fields) Entry
	Log()
}

func WithDebug

func WithDebug(format string) Entry

func WithError

func WithError(format string) Entry

func WithInfo

func WithInfo(format string) Entry

func WithWarn

func WithWarn(format string) Entry

type Field

type Field struct {
	Value any
	Call  FieldCall
}

type FieldCall

type FieldCall func(v any) any

type Fields

type Fields []Field

type Logger

type Logger interface {
	WithError(format string) Entry
	WithWarn(format string) Entry
	WithInfo(format string) Entry
	WithDebug(format string) Entry
	Errorf(format string, v ...any)
	Warnf(format string, v ...any)
	Infof(format string, v ...any)
	Debugf(format string, v ...any)
	SetLevel(level int)
}

type Options

type Options struct {
	OutDir     string `json:"out_dir" yaml:"out_dir" toml:"out_dir"`
	Filename   string `json:"filename" yaml:"filename" toml:"filename"`
	MaxSize    int    `json:"max_size" yaml:"max_size" toml:"max_size"`
	MaxBackups int    `json:"max_backups" yaml:"max_backups" toml:"max_backups"`
	MaxAge     int    `json:"max_age" yaml:"max_age" toml:"max_age"`
	Compress   bool   `json:"compress" yaml:"compress" toml:"compress"`
	Level      int    `json:"level" yaml:"level" toml:"level"`
	Async      bool   `json:"async" yaml:"async" toml:"async"`
}

func NewOptions

func NewOptions() Options

type Record

type Record struct {
	// contains filtered or unexported fields
}

func (*Record) Log

func (e *Record) Log()

func (*Record) WithField

func (e *Record) WithField(v any, call FieldCall) Entry

func (*Record) WithFields

func (e *Record) WithFields(fields Fields) Entry

func (*Record) WithFormat

func (e *Record) WithFormat(f string) Entry

func (*Record) WithLevel

func (e *Record) WithLevel(level int) Entry

func (*Record) WithTime

func (e *Record) WithTime(t time.Time) Entry

type WithConfig

type WithConfig func(*handler.Config)

func WithCompressConfig

func WithCompressConfig(compress bool) WithConfig

func WithFileNameConfig

func WithFileNameConfig(filename string, filterDefault bool) WithConfig

func WithLevelConfig

func WithLevelConfig(level int, filterDefault bool) WithConfig

func WithMaxAgeConfig

func WithMaxAgeConfig(maxAge int, filterDefault bool) WithConfig

func WithMaxBackupsConfig

func WithMaxBackupsConfig(maxBackups int, filterDefault bool) WithConfig

func WithMaxSizeConfig

func WithMaxSizeConfig(maxSize int, filterDefault bool) WithConfig

type WithOption

type WithOption func(o *Options)

func WithAsyncOption

func WithAsyncOption(async bool) WithOption

func WithCompressOption

func WithCompressOption(compress bool) WithOption

func WithFileNameOption

func WithFileNameOption(filename string, filterDefault bool) WithOption

func WithLevelOption

func WithLevelOption(level int, filterDefault bool) WithOption

func WithMaxAgeOption

func WithMaxAgeOption(maxAge int, filterDefault bool) WithOption

func WithMaxBackupsOption

func WithMaxBackupsOption(maxBackups int, filterDefault bool) WithOption

func WithMaxSizeOption

func WithMaxSizeOption(maxSize int, filterDefault bool) WithOption

func WithOutDirOption

func WithOutDirOption(outDir string, filterDefault bool) WithOption

Jump to

Keyboard shortcuts

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