yolog

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: MIT Imports: 12 Imported by: 0

README

yolog

yolog 第一版本是学习模仿项目

Documentation

Index

Constants

View Source
const (
	FmtEmptySeparate = ""
)

Variables

View Source
var LevelNameMapping = map[Level]string{
	DebugLevel: "DEBUG",
	InfoLevel:  "INFO",
	WarnLevel:  "WARN",
	ErrorLevel: "ERROR",
	PanicLevel: "PANIC",
	FatalLevel: "FATAL",
}

Functions

func Debug

func Debug(args ...interface{})

std logger

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 Info

func Info(args ...interface{})

func Infof

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

func New

func New(opts ...Option) *logger

func Panic

func Panic(args ...interface{})

func Panicf

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

func SetOptions

func SetOptions(opts ...Option)

func StdLogger

func StdLogger() *logger

func Warn

func Warn(args ...interface{})

func Warnf

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

func Writer

func Writer() io.Writer

Types

type Entry

type Entry struct {
	Buffer *bytes.Buffer          // 缓冲区
	Map    map[string]interface{} // json序列化format
	Level  Level                  // 写入的日志级别
	Time   time.Time              // 日志写入时间
	File   string                 // 反射拿到记录日志的文件名
	Line   int                    // 反射拿到记录日志的行号
	Func   string                 // 反射拿到记录日志的函数名
	Format string                 // 日志的格式化样式
	Args   []interface{}          // 写入日志的具体内容
	// contains filtered or unexported fields
}

Entry 将日志输出到支持的输出中

type Formatter

type Formatter interface {
	// Maybe in async goroutine
	// Please write the result to buffer
	Format(entry *Entry) error
}

type JsonFormatter

type JsonFormatter struct {
	IgnoreBasicFields bool
}

func (*JsonFormatter) Format

func (f *JsonFormatter) Format(e *Entry) error

type Level

type Level uint8

Level 日志级别

const (
	DebugLevel Level = iota
	InfoLevel
	WarnLevel
	ErrorLevel
	PanicLevel
	FatalLevel
)

func (*Level) UnmarshalText

func (l *Level) UnmarshalText(text []byte) error

type Option

type Option func(*options)

func WithDisableCaller

func WithDisableCaller(caller bool) Option

func WithFormatter

func WithFormatter(formatter Formatter) Option

func WithLevel

func WithLevel(level Level) Option

WithLevel 返回带level的Option

func WithOutput

func WithOutput(output io.Writer) Option

func WithStdLevel

func WithStdLevel(level Level) Option

type TextFormatter

type TextFormatter struct {
	IgnoreBasicFields bool
}

func (*TextFormatter) Format

func (f *TextFormatter) Format(e *Entry) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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