log

package
v0.0.0-...-13bfcb2 Latest Latest
Warning

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

Go to latest
Published: May 18, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultLevel      = Info
	DefaultFormat     = Json
	DefaultWriter     = os.Stdout
	DefaultCallerSkip = 0
)

Functions

func New

func New(options ...Option) *zap.Logger

Types

type Format

type Format string

Format 日志格式

const (
	Text Format = "text"
	Json Format = "json"
)

type Level

type Level string

Level 日志等级

const (
	Debug Level = "debug"
	Info  Level = "info"
	Warn  Level = "warn"
	Error Level = "error"
	Panic Level = "panic"
	Fatal Level = "fatal"
)

func (Level) Convert

func (l Level) Convert() zapcore.Level

type Logger

type Logger struct {
	Level      Level
	Format     Format
	Writer     io.Writer
	CallerSkip int
}

Logger 日志

type Option

type Option func(logger *Logger)

func WithCallerSkip

func WithCallerSkip(skip int) Option

WithCallerSkip 设置日志跳过的层级

func WithFormat

func WithFormat(format Format) Option

WithFormat 设置日志输出的格式

func WithLevel

func WithLevel(level Level) Option

WithLevel 设置日志等级

func WithWriter

func WithWriter(writer io.Writer) Option

WithWriter 设置日志输出的 Writer

Jump to

Keyboard shortcuts

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