logger

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package logger 日志

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fields

type Fields map[string]any

Fields 日志字段

type Level

type Level int8

Level 日志等级

const (
	LevelDebug Level = iota // LevelDebug Debug
	LevelInfo               // LevelInfo Info
	LevelWarn               // LevelWarn Warn
	LevelError              // LevelError Error
	LevelFatal              // LevelFatal Fatal
	LevelPanic              // LevelPanic Panic
)

func (Level) String

func (l Level) String() string

String returns a string representation of level

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger 日志结构体

func NewLogger

func NewLogger(w io.Writer, prefix string, flag int) *Logger

NewLogger 新建日志

func (*Logger) Debug

func (l *Logger) Debug(v ...any)

Debug 输出Debug级别日志

func (*Logger) Debugf

func (l *Logger) Debugf(format string, v ...any)

Debugf 格式化输出Debug级别日志

func (*Logger) Error

func (l *Logger) Error(v ...any)

Error 输出Error级别日志

func (*Logger) Errorf

func (l *Logger) Errorf(format string, v ...any)

Errorf 格式化输出Error级别日志

func (*Logger) Fatal

func (l *Logger) Fatal(v ...any)

Fatal 输出Fatal级别日志

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, v ...any)

Fatalf 格式化输出Fatal级别日志

func (*Logger) Info

func (l *Logger) Info(v ...any)

Info 输出Info级别日志

func (*Logger) Infof

func (l *Logger) Infof(format string, v ...any)

Infof 格式化输出Info级别日志

func (*Logger) JSONFormat

func (l *Logger) JSONFormat(level Level, message string) map[string]any

JSONFormat 将日志格式化为JSON

func (*Logger) Output

func (l *Logger) Output(level Level, message string)

Output 输出日志

func (*Logger) Panic

func (l *Logger) Panic(v ...any)

Panic 输出Panic级别日志,并触发 panic

func (*Logger) Panicf

func (l *Logger) Panicf(format string, v ...any)

Panicf 格式化输出Panic级别日志,并触发 panic

func (*Logger) Warn

func (l *Logger) Warn(v ...any)

Warn 输出Warn级别日志

func (*Logger) Warnf

func (l *Logger) Warnf(format string, v ...any)

Warnf 格式化输出Warn级别日志

func (*Logger) WithCaller

func (l *Logger) WithCaller(skip int) *Logger

WithCaller 设置当前某一层的调用栈信息

func (*Logger) WithCallerFrames

func (l *Logger) WithCallerFrames() *Logger

WithCallerFrames 设置当前的整个调用栈信息

func (*Logger) WithContext

func (l *Logger) WithContext(ctx context.Context) *Logger

WithContext 设置日志上下文字段

func (*Logger) WithFields

func (l *Logger) WithFields(f Fields) *Logger

WithFields 设置日志公共字段

Jump to

Keyboard shortcuts

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