logger

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 11 Imported by: 5

Documentation

Index

Constants

View Source
const (
	HTTPModule  = "http"
	CrashModule = "crash"
)
View Source
const (
	LogFilename = "application.log"
)

Variables

View Source
var (
	AccessLog = GetLogger(HTTPModule, "Access")
	CrashLog  = GetLogger(CrashModule, "Crash")
)
View Source
var (
	RunningAtomicLevel = zap.NewAtomicLevelAt(zapcore.InfoLevel) // 设置日志等级
)

Functions

func Any

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

func Error

func Error(err error) zap.Field

func Int32

func Int32(key string, val int32) zap.Field

func Int64

func Int64(key string, val int64) zap.Field

func IsTerminal

func IsTerminal(f *os.File) bool

linux 系统 stdout输出

func LevelString

func LevelString(l zapcore.Level) string

func NewLogger

func NewLogger(cfg config.Logging) error

NewLogger initializes a zap logger from user config

func Reflect

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

func SimpleAccessLevelEncoder

func SimpleAccessLevelEncoder(l zapcore.Level, enc zapcore.PrimitiveArrayEncoder)

func SimpleLevelEncoder

func SimpleLevelEncoder(l zapcore.Level, enc zapcore.PrimitiveArrayEncoder)

func SimpleTimeEncoder

func SimpleTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)

func Stack

func Stack() zap.Field

func String

func String(key string, val string) zap.Field

func Uint16

func Uint16(key string, val uint16) zap.Field

func Uint32

func Uint32(key string, val uint32) zap.Field

Types

type Logger

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

func GetLogger

func GetLogger(module, role string) *Logger

GetLogger return logger with module name

func (*Logger) Debug

func (l *Logger) Debug(msg string, fields ...zap.Field)

TODO: append 浅拷贝问题

func (*Logger) Error

func (l *Logger) Error(msg string, fields ...zap.Field)

func (*Logger) Info

func (l *Logger) Info(msg string, fields ...zap.Field)

func (*Logger) Warn

func (l *Logger) Warn(msg string, fields ...zap.Field)

Jump to

Keyboard shortcuts

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