xlog

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(args ...interface{})

Debug ...

func Debugf

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

Debugf ...

func Error

func Error(args ...interface{})

Error ...

func Errorf

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

Errorf ...

func Fatal

func Fatal(args ...interface{})

Fatal ...

func Fatalf

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

Fatalf ...

func Info

func Info(args ...interface{})

Info ...

func Infof

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

Infof ...

func Panic

func Panic(args ...interface{})

Panic ...

func Panicf

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

Panicf ...

func Trace

func Trace(args ...interface{})

Trace ...

func Tracef

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

Tracef ...

func Warn

func Warn(args ...interface{})

Warn ...

func Warnf

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

Warnf ...

func Writer

func Writer() io.Writer

Writer ...

Types

type Config

type Config struct {
	Type      Type      `yaml:"type"`        // 日志类型
	Level     Level     `yaml:"level"`       // 日志级别
	Formatter Formatter `yaml:"formatter"`   // 输出格式
	Filepath  string    `yaml:"output_file"` // 文件路径
	Stdout    bool      `yaml:"stdout"`      // 输出终端
}

Config ...

type Fields

type Fields map[string]interface{}

Fields ...

type Formatter

type Formatter string

Formatter ...

const (
	FormatterJSON Formatter = "json"
	FormatterText Formatter = "text"
)

格式化类型

type Level

type Level string

Level ...

const (
	LevelTrace Level = "trace"
	LevelDebug Level = "debug"
	LevelInfo  Level = "info"
	LevelWarn  Level = "warn"
	LevelError Level = "error"
	LevelFatal Level = "fatal"
	LevelPanic Level = "panic"
)

日志级别

type Logger

type Logger interface {
	Log(level Level, args ...interface{})                 // 记录对应级别的日志
	Logf(level Level, format string, args ...interface{}) // 记录对应级别的日志
	Trace(args ...interface{})                            // 记录 TraceLevel 级别的日志
	Tracef(format string, args ...interface{})            // 格式化并记录 TraceLevel 级别的日志
	Debug(args ...interface{})                            // 记录 DebugLevel 级别的日志
	Debugf(format string, args ...interface{})            // 格式化并记录 DebugLevel 级别的日志
	Info(args ...interface{})                             // 记录 InfoLevel 级别的日志
	Infof(format string, args ...interface{})             // 格式化并记录 InfoLevel 级别的日志
	Warn(args ...interface{})                             // 记录 WarnLevel 级别的日志
	Warnf(format string, args ...interface{})             // 格式化并记录 WarnLevel 级别的日志
	Error(args ...interface{})                            // 记录 ErrorLevel 级别的日志
	Errorf(format string, args ...interface{})            // 格式化并记录 ErrorLevel 级别的日志
	Fatal(args ...interface{})                            // 记录 FatalLevel 级别的日志
	Fatalf(format string, args ...interface{})            // 格式化并记录 FatalLevel 级别的日志
	Panic(args ...interface{})                            // 记录 PanicLevel 级别的日志
	Panicf(format string, args ...interface{})            // 格式化并记录 PanicLevel 级别的日志
	WithField(key string, value interface{}) Logger       // 为日志添加一个上下文数据
	Writer() io.Writer                                    // 返回日志 io.Writer
}

Logger ...

func NewLogger

func NewLogger(options ...Option) Logger

NewLogger ...

type Option

type Option func(*Config)

Option ...

func WithFile

func WithFile(filepath string, stdouts ...bool) Option

WithFile ...

func WithFormatter

func WithFormatter(formatter Formatter) Option

WithFormatter ...

func WithLevel

func WithLevel(level Level) Option

WithLevel ...

func WithLogger

func WithLogger(logger Type) Option

WithLogger ...

type Type

type Type int

Type ...

const (
	TypeZap Type = iota
	TypeLogrus
)

日志类型

func (Type) String

func (t Type) String() string

String ...

Jump to

Keyboard shortcuts

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