hlogging

package
v0.0.0-...-e3e94bd Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	CONSOLE = iota
	JSON
	LOGFMT
)
View Source
const (
	DefaultFormat = "" /* 159-byte string literal not displayed */

)
View Source
const DisabledLevel = zapcore.Level(math.MinInt8)
View Source
const (
	ShortFuncFormat = "" /* 160-byte string literal not displayed */
)

Variables

This section is empty.

Functions

func ActivateSpec

func ActivateSpec(spec string)

ActivateSpec 接收的字符串 spec 的格式是:logger1,logger2=level:logger3=level:level。没有指定 logger 的 level 会被作为默认日志等级。

func DefaultLevel

func DefaultLevel() string

func Init

func Init(config Config)

func IsValidLevel

func IsValidLevel(level string) bool

func LoggerLevel

func LoggerLevel(loggerName string) string

LoggerLevel 返回对应 loggerName 的日志等级。

func NameToLevel

func NameToLevel(level string) zapcore.Level

NameToLevel 如果给定的字符串 level 所指示的日志等级是未知的,则返回 InfoLevel,否则返回与 level 对应的 zapcore.Level。

func NewZapLogger

func NewZapLogger(core zapcore.Core, options ...zap.Option) *zap.Logger

func Reset

func Reset()

Reset 调用 Global.Apply(Config{}) 重置配置信息。

func SetWriter

func SetWriter(w io.Writer) io.Writer

Types

type Config

type Config struct {
	Format  string
	LogSpec string
	Writer  io.Writer
}

type Encoding

type Encoding int8

type EncodingSelector

type EncodingSelector interface {
	Encoding() Encoding
}

type HyperchainLogger

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

func MustGetLogger

func MustGetLogger(loggerName string) *HyperchainLogger

func NewHyperchainLogger

func NewHyperchainLogger(l *zap.Logger, options ...zap.Option) *HyperchainLogger

func (*HyperchainLogger) Debug

func (hl *HyperchainLogger) Debug(args ...interface{})

func (*HyperchainLogger) Debugf

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

func (*HyperchainLogger) Debugw

func (hl *HyperchainLogger) Debugw(msg string, kvs ...interface{})

func (*HyperchainLogger) Error

func (hl *HyperchainLogger) Error(args ...interface{})

func (*HyperchainLogger) Errorf

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

func (*HyperchainLogger) Errorw

func (hl *HyperchainLogger) Errorw(msg string, kvs ...interface{})

func (*HyperchainLogger) Info

func (hl *HyperchainLogger) Info(args ...interface{})

func (*HyperchainLogger) Infof

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

func (*HyperchainLogger) Infow

func (hl *HyperchainLogger) Infow(msg string, kvs ...interface{})

func (*HyperchainLogger) IsEnabledFor

func (hl *HyperchainLogger) IsEnabledFor(level zapcore.Level) bool

func (*HyperchainLogger) Named

func (hl *HyperchainLogger) Named(name string) *HyperchainLogger

func (*HyperchainLogger) Panic

func (hl *HyperchainLogger) Panic(args ...interface{})

func (*HyperchainLogger) Panicf

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

func (*HyperchainLogger) Panicw

func (hl *HyperchainLogger) Panicw(msg string, kvs ...interface{})

func (*HyperchainLogger) Warn

func (hl *HyperchainLogger) Warn(args ...interface{})

func (*HyperchainLogger) Warnf

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

func (*HyperchainLogger) Warnw

func (hl *HyperchainLogger) Warnw(msg string, kvs ...interface{})

func (*HyperchainLogger) With

func (hl *HyperchainLogger) With(args ...interface{}) *HyperchainLogger

type LoggerLevels

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

func (*LoggerLevels) ActivateSpec

func (ll *LoggerLevels) ActivateSpec(spec string) error

ActivateSpec 接收的字符串 spec 的格式是:logger1,logger2=level:logger3=level:level。没有指定 logger 的 level 会被作为默认日志等级。

func (*LoggerLevels) DefaultLevel

func (ll *LoggerLevels) DefaultLevel() zapcore.Level

func (*LoggerLevels) Enabled

func (ll *LoggerLevels) Enabled(lvl zapcore.Level) bool

Enabled 判断给定的日志等级 level 是否高于或等于 LoggerLevels 的 minLevel。

func (*LoggerLevels) Level

func (ll *LoggerLevels) Level(loggerName string) zapcore.Level

Level 返回与给定的 loggerName 绑定的日志等级,首先从缓冲区中寻找有没有存储 loggerName:level,如果没有,那么再递归地从 specs 中寻找,例如给定的 loggerName 是 aaa.bbb.ccc,在 specs 中存储了 aaa.bbb:InfoLevel,那么返回的日志记录等级就是 InfoLevel。

func (*LoggerLevels) Spec

func (ll *LoggerLevels) Spec() string

type Logging

type Logging struct {
	*LoggerLevels
	// contains filtered or unexported fields
}
var Global *Logging

func NewLogging

func NewLogging(c Config) (*Logging, error)

func (*Logging) Apply

func (l *Logging) Apply(c Config) error

func (*Logging) Check

func (l *Logging) Check(e zapcore.Entry, ce *zapcore.CheckedEntry)

func (*Logging) Encoding

func (l *Logging) Encoding() Encoding

func (*Logging) Logger

func (l *Logging) Logger(name string) *HyperchainLogger

func (*Logging) SetFormat

func (l *Logging) SetFormat(format string) error

func (*Logging) SetObserver

func (l *Logging) SetObserver(o Observer) Observer

func (*Logging) SetWriter

func (l *Logging) SetWriter(w io.Writer) io.Writer

func (*Logging) Sync

func (l *Logging) Sync() error

func (*Logging) Write

func (l *Logging) Write(b []byte) (int, error)

func (*Logging) WriteEntry

func (l *Logging) WriteEntry(e zapcore.Entry, fields []zapcore.Field)

func (*Logging) ZapLogger

func (l *Logging) ZapLogger(name string) *zap.Logger

type Observer

type Observer interface {
	Check(e zapcore.Entry, ce *zapcore.CheckedEntry)
	WriteEntry(e zapcore.Entry, fields []zapcore.Field)
}

func SetObserver

func SetObserver(o Observer) Observer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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