logger

package
v0.0.0-...-04e6e7a Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2022 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// DebugLevel logs are typically voluminous, and are usually disabled in
	// production.
	DebugLevel = zap.DebugLevel
	// InfoLevel is the default logging priority.
	InfoLevel = zap.InfoLevel
	// WarnLevel logs are more important than Info, but don't need individual
	// human review.
	WarnLevel = zap.WarnLevel
	// ErrorLevel logs are high-priority. If an application is running smoothly,
	// it shouldn't generate any error-Level logs.
	ErrorLevel = zap.ErrorLevel
	// PanicLevel logs a message, then panics.
	PanicLevel = zap.PanicLevel
	// FatalLevel logs a message, then calls os.Exit(1).
	FatalLevel = zap.FatalLevel
)

Variables

View Source
var (
	// String ...
	String = zap.String
	// Any ...
	Any = zap.Any
	// Int64 ...
	Int64 = zap.Int64
	// Int ...
	Int = zap.Int
	// Int32 ...
	Int32 = zap.Int32
	// Uint ...
	Uint = zap.Uint
	// Duration ...
	Duration = zap.Duration
	// Durationp ...
	Durationp = zap.Durationp
	// Object ...
	Object = zap.Object
	// Namespace ...
	Namespace = zap.Namespace
	// Reflect ...
	Reflect = zap.Reflect
	// Skip ...
	Skip = zap.Skip()
	// ByteString ...
	ByteString = zap.ByteString
)
View Source
var (
	DefaultLogger = Config{
		Debug:      true,
		Stdout:     true,
		AddCaller:  false,
		CallerSkip: 1,
	}.Build()
	FrameLogger = Config{
		Debug:      true,
		Stdout:     true,
		AddCaller:  false,
		CallerSkip: 1,
	}.Build()
)

Functions

func DPanic

func DPanic(args ...interface{})

func DPanicd

func DPanicd(msg string, fields ...Field)

func DPanicf

func DPanicf(template string, args ...interface{})

func DPanicw

func DPanicw(msg string, keysAndValues ...interface{})

func Debug

func Debug(args ...interface{})

Sugar

func Debugd

func Debugd(msg string, fields ...Field)

func Debugf

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

Sugar f

func Debugw

func Debugw(msg string, keysAndValues ...interface{})

Sugar w

func Error

func Error(args ...interface{})

func Errord

func Errord(msg string, fields ...Field)

func Errorf

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

func Errorw

func Errorw(msg string, keysAndValues ...interface{})

func FieldAid

func FieldAid(aid string) zap.Field

FieldAid 应用id

func FieldAny

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

FieldAny 二级封装zap.any

func FieldCode

func FieldCode(code interface{}) zap.Field

FieldCode 日志发生的执行代码

func FieldErr

func FieldErr(err error) zap.Field

FieldErr 错误信息

func FieldHost

func FieldHost(host string) zap.Field

FieldHost 日志发生的主机名

func FieldIp

func FieldIp(ip string) zap.Field

FieldIp 日志发生的主机ip

func FieldMod

func FieldMod(mod string) zap.Field

FieldMod 日志发生的模块

func FieldString

func FieldString(key, val string) zap.Field

FieldString 二级封装zap.string

func FieldTid

func FieldTid(tid string) zap.Field

FieldTid 日志发生的链路追踪id

func FieldValue

func FieldValue(value interface{}) zap.Field

FieldValue 错误发生相关的值

func Info

func Info(args ...interface{})

func Infod

func Infod(msg string, fields ...Field)

func Infof

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

func Infow

func Infow(msg string, keysAndValues ...interface{})

func Panic

func Panic(args ...interface{})

func Panicd

func Panicd(msg string, fields ...Field)

func Panicf

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

func Panicw

func Panicw(msg string, keysAndValues ...interface{})

func Warn

func Warn(args ...interface{})

func Warnd

func Warnd(msg string, fields ...Field)

func Warnf

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

func Warnw

func Warnw(msg string, keysAndValues ...interface{})

Types

type Config

type Config struct {
	Debug      bool        `json:"debug"`       // 是否开启debug模式,默认false
	Stdout     bool        `json:"stdout"`      // 终端输出日志
	Level      string      `json:"level"`       // 日志等级
	Fields     []zap.Field `json:"fields"`      // 初始化字段
	AddCaller  bool        `json:"add_caller"`  // 是否打印调用者信息,默认,true
	TimeFormat string      `json:"time_format"` // 时间格式化
	CallerSkip int         `json:"caller_skip"` // 表示输出当前栈帧,默认,1

	Core          zapcore.Core
	EncoderConfig *zapcore.EncoderConfig `json:"encoder_config"` // 日志编码设置

	Writers map[string]interface{} `json:"writers"` // 配置信息
	// contains filtered or unexported fields
}

func RawConfig

func RawConfig(key string) *Config

RawConfig 根据key构建配置

func ScanConfig

func ScanConfig(name string) *Config

ScanConfig 根据name构建配置

func (*Config) AddWriter

func (c *Config) AddWriter(writer writer.Writer) *Config

AddWriter 添加日志输出者

func (Config) Build

func (c Config) Build() *Logger

Build 创建logger

type Field

type Field = zap.Field

type Func

type Func func(string, ...zap.Field)

type Interface

type Interface interface {
	// Sugar
	Debug(args ...interface{})
	Info(args ...interface{})
	Warn(args ...interface{})
	Error(args ...interface{})
	DPanic(args ...interface{})
	Panic(args ...interface{})
	// Sugar f
	Debugf(template string, args ...interface{})
	Infof(template string, args ...interface{})
	Warnf(template string, args ...interface{})
	Errorf(template string, args ...interface{})
	DPanicf(template string, args ...interface{})
	Panicf(template string, args ...interface{})
}

type Level

type Level = zapcore.Level

type Logger

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

func (*Logger) AddCallerSkip

func (l *Logger) AddCallerSkip(i int) *Logger

AddCallerSkip 跨栈调用,增加栈

func (*Logger) AutoLevel

func (l *Logger) AutoLevel(key string)

func (*Logger) DPanic

func (l *Logger) DPanic(args ...interface{})

func (*Logger) DPanicd

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

func (*Logger) DPanicf

func (l *Logger) DPanicf(template string, args ...interface{})

func (*Logger) DPanicw

func (l *Logger) DPanicw(msg string, keysAndValues ...interface{})

func (*Logger) Debug

func (l *Logger) Debug(args ...interface{})

Sugar

func (*Logger) Debugd

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

DeSugar

func (*Logger) Debugf

func (l *Logger) Debugf(template string, args ...interface{})

Sugar f

func (*Logger) Debugw

func (l *Logger) Debugw(msg string, keysAndValues ...interface{})

Sugar w

func (*Logger) Error

func (l *Logger) Error(args ...interface{})

func (*Logger) Errord

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

func (*Logger) Errorf

func (l *Logger) Errorf(template string, args ...interface{})

func (*Logger) Errorw

func (l *Logger) Errorw(msg string, keysAndValues ...interface{})

func (*Logger) Info

func (l *Logger) Info(args ...interface{})

func (*Logger) Infod

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

func (*Logger) Infof

func (l *Logger) Infof(template string, args ...interface{})

func (*Logger) Infow

func (l *Logger) Infow(msg string, keysAndValues ...interface{})

func (*Logger) Panic

func (l *Logger) Panic(args ...interface{})

func (*Logger) Panicd

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

func (*Logger) Panicf

func (l *Logger) Panicf(template string, args ...interface{})

func (*Logger) Panicw

func (l *Logger) Panicw(msg string, keysAndValues ...interface{})

func (*Logger) SetLevel

func (l *Logger) SetLevel(level Level) *Logger

SetLevel 主动设置等级

func (*Logger) Warn

func (l *Logger) Warn(args ...interface{})

func (*Logger) Warnd

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

func (*Logger) Warnf

func (l *Logger) Warnf(template string, args ...interface{})

func (*Logger) Warnw

func (l *Logger) Warnw(msg string, keysAndValues ...interface{})

func (*Logger) With

func (l *Logger) With(fields ...Field) *Logger

func (*Logger) ZapLogger

func (l *Logger) ZapLogger() *zap.Logger

ZapLogger 获取zapLogger

Directories

Path Synopsis
bufferpool
Package bufferpool houses zap's shared internal buffer pool.
Package bufferpool houses zap's shared internal buffer pool.

Jump to

Keyboard shortcuts

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