logger

package
v0.0.0-...-9f02567 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimeFormat = "2006-01-02T15:04:05.000"
)

Variables

This section is empty.

Functions

func Debug

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

func DebugToConsole

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

func DebugToFile

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

func Error

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

func ErrorToConsole

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

func ErrorToFile

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

func Info

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

func InfoToConsole

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

func InfoToFile

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

func SetLogTime

func SetLogTime(timeFormat string, utc bool)

func Warn

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

func WarnToConsole

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

func WarnToFile

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

func ZeroHook

func ZeroHook(h Hook) zeroHook

Types

type Config

type Config struct {
	Level               string `json:"level" mapstructure:"level"`
	TimeFormat          string `json:"time_format" mapstructure:"time_format"`
	FilePath            string `json:"filepath" mapstructure:"filepath"`
	AccessFilePath      string `json:"access_filepath" mapstructure:"access_filepath"`
	MaxSize             int    `json:"max_size" mapstructure:"max_size"`
	MaxAge              int    `json:"max_age" mapstructure:"max_age"`
	MaxBackups          int    `json:"max_backups" mapstructure:"max_backups"`
	Compress            bool   `json:"compress" mapstructure:"compress"`
	UTCTime             bool   `json:"utc_time" mapstructure:"utc_time"`
	EnableFile          bool   `json:"enable_file" mapstructure:"enable_file"`
	EnableConsole       bool   `json:"enable_console" mapstructure:"enable_console"`
	EnableAccessFile    bool   `json:"enable_access_file" mapstructure:"enable_access_file"`
	EnableAccessConsole bool   `json:"enable_access_console" mapstructure:"enable_access_console"`
}

func (*Config) Init

func (c *Config) Init() error

type Event

type Event = zerolog.Event

type Hook

type Hook interface {
	Run(e *Event, level Level, message string)
}

type HookFunc

type HookFunc func(e *Event, level Level, message string)

HookFunc is an adaptor to allow the use of an ordinary function as a Hook.

func (HookFunc) Run

func (h HookFunc) Run(e *Event, level Level, message string)

Run implements the zerolog.Hook interface.

type Level

type Level int
const (
	DEBUG Level = iota - 1
	INFO
	WARN
	ERROR
)

func (Level) String

func (l Level) String() string

type Logger

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

func AutoSkipFrameCount

func AutoSkipFrameCount() *Logger

func GetAccessLogger

func GetAccessLogger() *Logger

func GetLogger

func GetLogger() *Logger

func New

func New(c Config) (logger Logger, err error)

func With

func With(key string, a any) *Logger

func WithCaller

func WithCaller() *Logger

func WithHook

func WithHook(h Hook) *Logger

func WithHookFunc

func WithHookFunc(h HookFunc) *Logger

func WithRequestID

func WithRequestID(id string) *Logger

func WithSender

func WithSender(sender string) *Logger

func WithSkipFrameCount

func WithSkipFrameCount(skip int) *Logger

func (Logger) AutoSkipFrameCount

func (l Logger) AutoSkipFrameCount() *Logger

func (Logger) Debug

func (l Logger) Debug(format string, v ...any)

func (Logger) DebugToConsole

func (l Logger) DebugToConsole(format string, v ...any)

func (Logger) DebugToFile

func (l Logger) DebugToFile(format string, v ...any)

func (Logger) Error

func (l Logger) Error(format string, v ...any)

func (Logger) ErrorToConsole

func (l Logger) ErrorToConsole(format string, v ...any)

func (Logger) ErrorToFile

func (l Logger) ErrorToFile(format string, v ...any)

func (Logger) Info

func (l Logger) Info(format string, v ...any)

func (Logger) InfoToConsole

func (l Logger) InfoToConsole(format string, v ...any)

func (Logger) InfoToFile

func (l Logger) InfoToFile(format string, v ...any)

func (Logger) Warn

func (l Logger) Warn(format string, v ...any)

func (Logger) WarnToConsole

func (l Logger) WarnToConsole(format string, v ...any)

func (Logger) WarnToFile

func (l Logger) WarnToFile(format string, v ...any)

func (Logger) With

func (l Logger) With(key string, val any) *Logger

func (Logger) WithCaller

func (l Logger) WithCaller() *Logger

func (Logger) WithHook

func (l Logger) WithHook(h Hook) *Logger

func (Logger) WithHookFunc

func (l Logger) WithHookFunc(h HookFunc) *Logger

func (Logger) WithRequestID

func (l Logger) WithRequestID(id string) *Logger

func (Logger) WithSender

func (l Logger) WithSender(sender string) *Logger

func (Logger) WithSkipFrameCount

func (l Logger) WithSkipFrameCount(skip int) *Logger

Jump to

Keyboard shortcuts

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