zlog

package
v1.0.153 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEBUG = "debug"
	INFO  = "info"
	WARN  = "warn"
	ERROR = "error"
	FATAL = "fatal"
)

Variables

This section is empty.

Functions

func AddError

func AddError(errs ...error) zap.Field

func Any

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

func Array

func Array(key string, val zapcore.ArrayMarshaler) zap.Field

func Binary

func Binary(key string, val []byte) zap.Field

func Bool

func Bool(key string, val bool) zap.Field

func Bools

func Bools(key string, bs []bool) zap.Field

func ByteString

func ByteString(key string, val []byte) zap.Field

func ByteStrings

func ByteStrings(key string, bss [][]byte) zap.Field

func Complex128

func Complex128(key string, val complex128) zap.Field

func Complex128s

func Complex128s(key string, nums []complex128) zap.Field

func Complex64

func Complex64(key string, val complex64) zap.Field

func Complex64s

func Complex64s(key string, nums []complex64) zap.Field

func DPanic

func DPanic(msg string, start int64, fields ...zap.Field)

dpanic

func Debug

func Debug(msg string, start int64, fields ...zap.Field)

debug

func Duration

func Duration(key string, val time.Duration) zap.Field

func Durations

func Durations(key string, ds []time.Duration) zap.Field

func Error

func Error(msg string, start int64, fields ...zap.Field)

error

func Errors

func Errors(key string, errs ...error) zap.Field

func Fatal

func Fatal(msg string, start int64, fields ...zap.Field)

fatal

func Float32

func Float32(key string, val float32) zap.Field

func Float32s

func Float32s(key string, nums []float32) zap.Field

func Float64

func Float64(key string, val float64) zap.Field

func Float64s

func Float64s(key string, nums []float64) zap.Field

func GetLevel

func GetLevel(str string) zapcore.Level

字符串级别类型转具体类型

func Info

func Info(msg string, start int64, fields ...zap.Field)

info

func InitDefaultLog

func InitDefaultLog(config *ZapConfig) *zap.Logger

通过配置初始化默认日志对象

func InitNewLog

func InitNewLog(config *ZapConfig) *zap.Logger

通过配置创建新的日志对象

func Int

func Int(key string, val int) zap.Field

func Int16

func Int16(key string, val int16) zap.Field

func Int16s

func Int16s(key string, nums []int16) zap.Field

func Int32

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

func Int32s

func Int32s(key string, nums []int32) zap.Field

func Int64

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

func Int64s

func Int64s(key string, nums []int64) zap.Field

func Int8

func Int8(key string, val int8) zap.Field

func Int8s

func Int8s(key string, nums []int8) zap.Field

func Ints

func Ints(key string, nums []int) zap.Field

func IsDebug

func IsDebug() bool

is debug?

func Namespace

func Namespace(key string) zap.Field

func NewTimeEncoder added in v1.0.132

func NewTimeEncoder(layout string, location *time.Location) func(t time.Time, enc zapcore.PrimitiveArrayEncoder)

func Object

func Object(key string, val zapcore.ObjectMarshaler) zap.Field

func Panic

func Panic(msg string, start int64, fields ...zap.Field)

panic

func Print

func Print(v ...interface{})

兼容原生log.Print

func Printf

func Printf(format string, v ...interface{})

兼容原生log.Printf

func Println

func Println(v ...interface{})

兼容原生log.Println

func Reflect

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

func Skip

func Skip() zap.Field

func Stack

func Stack(key string) zap.Field

func String

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

func Stringer

func Stringer(key string, val fmt.Stringer) zap.Field

func Strings

func Strings(key string, ss []string) zap.Field

func Time

func Time(key string, val time.Time) zap.Field

func Times

func Times(key string, ts []time.Time) zap.Field

func Uint

func Uint(key string, val uint) zap.Field

func Uint16

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

func Uint16s

func Uint16s(key string, nums []uint16) zap.Field

func Uint32

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

func Uint32s

func Uint32s(key string, nums []uint32) zap.Field

func Uint64

func Uint64(key string, val uint64) zap.Field

func Uint64s

func Uint64s(key string, nums []uint64) zap.Field

func Uint8

func Uint8(key string, val uint8) zap.Field

func Uint8s

func Uint8s(key string, nums []uint8) zap.Field

func Uintptr

func Uintptr(key string, val uintptr) zap.Field

func Uintptrs

func Uintptrs(key string, us []uintptr) zap.Field

func Uints

func Uints(key string, nums []uint) zap.Field

func Warn

func Warn(msg string, start int64, fields ...zap.Field)

warn

Types

type FileConfig

type FileConfig struct {
	Filename   string // 日志文件路径
	MaxSize    int    // 每个日志文件保存的最大尺寸 单位:M
	MaxBackups int    // 日志文件最多保存多少个备份
	MaxAge     int    // 文件最多保存多少天
	Compress   bool   // 是否压缩
}

日志文件输出配置

type ZapConfig

type ZapConfig struct {
	Layout     int64              // 时间格式, 0.输出日期格式 1.输出毫秒时间戳
	Location   *time.Location     // 时间地区, 默认上海
	Level      string             // 日志级别
	Console    bool               // 是否控制台输出
	FileConfig *FileConfig        // 输出文件配置
	Callfunc   func([]byte) error // 回调函数
}

日志初始化配置

type ZapLog

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

type ZapProducer

type ZapProducer struct {
	Callfunc func([]byte) error // 回调函数
}

第三方发送对象实现

func (*ZapProducer) Write

func (self *ZapProducer) Write(b []byte) (n int, err error)

第三方发送回调函数实现

Jump to

Keyboard shortcuts

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