logger

package module
v0.0.0-...-caed9cc Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: Apache-2.0 Imports: 6 Imported by: 3

README

logger test

Documentation

Overview

Package logger Date: 2024/03/20 12:11:50 Author: Amu Description:

Package logger Date: 2024/03/19 17:51:13 Author: Amu Description:

Package logger Date: 2024/03/19 17:09:20 Author: Amu Description:

Index

Constants

View Source
const (
	LevelDebug = slog.LevelDebug
	LevelInfo  = slog.LevelInfo
	LevelWarn  = slog.LevelWarn
	LevelError = slog.LevelError
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Name                string     `load:"load"`     // 【默认】Logger 名称
	LogFile             string     `load:"load.log"` // 【默认】日志文件名称
	LogLevel            slog.Level `load:"info"`     // 【默认】日志打印级别
	LogFileRotationTime int        `load:"1"`        // 【默认】日志文件切割间隔,单位 D
	LogFileMaxAge       int        `load:"7"`        // 【默认】日志文件保留时间,单位 D
	LogFileSuffix       string     `load:".%Y%m%d"`  // 【默认】归档日志后缀
}

type Logger

type Logger struct {
	*slog.Logger
}

func NewJsonFileLogger

func NewJsonFileLogger(options ...Option) *Logger

func NewJsonLogger

func NewJsonLogger() *Logger

func NewTextLogger

func NewTextLogger() *Logger

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...interface{})

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...interface{})

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...interface{})

func (*Logger) SetDebugLevel

func (l *Logger) SetDebugLevel()

func (*Logger) SetErrorLevel

func (l *Logger) SetErrorLevel()

func (*Logger) SetInfoLevel

func (l *Logger) SetInfoLevel()

func (*Logger) SetWarnLevel

func (l *Logger) SetWarnLevel()

func (*Logger) Warnf

func (l *Logger) Warnf(format string, args ...interface{})

type Option

type Option func(*Config)

func SetLogFile

func SetLogFile(logFile string) Option

func SetLogFileMaxAge

func SetLogFileMaxAge(duration int) Option

func SetLogFileRotationTime

func SetLogFileRotationTime(duration int) Option

func SetLogFileSuffix

func SetLogFileSuffix(suffix string) Option

func SetLogLevel

func SetLogLevel(level string) Option

func SetName

func SetName(name string) Option

Jump to

Keyboard shortcuts

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