logx

package module
v0.0.0-...-07fd573 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 8 Imported by: 1

README

log

Golang log 工具封装

toml 配置实例

[log]
Name = "test"                       # logger name
LogFile = "test.log"                # 日志输出文件名
LogLevel = "info"                   # 日志等级
LogFormat = "json"                  # 日志格式化方式,json text
LogFileRotationTime = 1             # 日志切割间隔,单位:D
LogFileMaxAge = 7                   # 日志切割间隔,单位:D
LogOutput = "file"                  # 日志输出位置,console file kafka
LogFileSuffix = ".%Y%m%d"           # 归档日志后缀,.20230411

Documentation

Overview

Package logx Date: 2023/4/10 17:18 Author: Amu Description:

Package logx Date: 2023/4/10 17:39 Author: Amu Description:

Package logx Date: 2023/4/10 17:23 Author: Amu Description:

Package logx Date: 2023/4/10 17:17 Author: Amu Description:

Package logx Date: 2023/4/10 17:14 Author: Amu Description:

Package logx Date: 2023/4/10 17:19 Author: Amu Description:

Package logx Date: 2023/4/10 17:24 Author: Amu Description:

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(args ...interface{})

func Debugf

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

func Error

func Error(args ...interface{})

func Errorf

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

func Fatal

func Fatal(args ...interface{})

func Fatalf

func Fatalf(format string, args ...interface{})

func Field

func Field(key string, value interface{}) zap.Field

func Info

func Info(args ...interface{})

func Infof

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

func NewLogger

func NewLogger(options ...Option)

func Panic

func Panic(args ...interface{})

func Panicf

func Panicf(format string, args ...interface{})

func Warn

func Warn(args ...interface{})

func Warnf

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

func WithField

func WithField(fields ...zap.Field)

Types

type Config

type Config struct {
	Name                string        `default:"std"`         // 【默认】Logger 名称
	LogFile             string        `default:"scanner.log"` // 【默认】日志文件名称
	LogLevel            zapcore.Level `default:"info"`        // 【默认】日志打印级别
	LogFormat           string        `default:"text"`        // 【默认】日志打印样式,支持 text 和 json
	LogFileRotationTime int           `default:"1"`           // 【默认】日志文件切割间隔,单位 D
	LogFileMaxAge       int           `default:"7"`           // 【默认】日志文件保留时间,单位 D
	LogOutput           string        `default:"stdout"`      // 【默认】日志输出位置,只会 stdout iohelper
	LogFileSuffix       string        `default:".%Y%m%d"`     // 【默认】归档日志后缀
}

type Logger

type Logger struct {
	*zap.Logger
	// contains filtered or unexported fields
}

func GetLogger

func GetLogger(name string) *Logger

func (*Logger) Debug

func (l *Logger) Debug(args ...interface{})

func (*Logger) Debugf

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

func (*Logger) Error

func (l *Logger) Error(args ...interface{})

func (*Logger) Errorf

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

func (*Logger) Fatal

func (l *Logger) Fatal(args ...interface{})

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, v ...interface{})

func (*Logger) Info

func (l *Logger) Info(args ...interface{})

func (*Logger) Infof

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

func (*Logger) NewLogger

func (l *Logger) NewLogger(options ...Option)

func (*Logger) Panic

func (l *Logger) Panic(args ...interface{})

func (*Logger) Panicf

func (l *Logger) Panicf(format string, v ...interface{})

func (*Logger) Warn

func (l *Logger) Warn(args ...interface{})

func (*Logger) Warnf

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

func (*Logger) WithField

func (l *Logger) WithField(fields ...zap.Field)

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 SetLogFormat

func SetLogFormat(format string) Option

func SetLogLevel

func SetLogLevel(level string) Option

func SetLogOutput

func SetLogOutput(output 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