zapm

package
v0.0.0-...-432d548 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

README

zapm (zap mate) provides helpers for zap library.

Documentation

Index

Constants

View Source
const (
	// MsgUKey defines this message uniq key to make diff
	MsgUKey = "ukey"
)

Variables

View Source
var (
	// Logger is the default logger
	Logger *zap.Logger
)

Functions

func InitDefault

func InitDefault(f string, opts ...zap.Option) error

InitDefault init default logger

func NewDiffCore

func NewDiffCore(enc zapcore.Encoder, ws zapcore.WriteSyncer, enab zapcore.LevelEnabler, cacheSize int, opts ...Option) zapcore.Core

NewDiffCore creates a Core only output logs when different.

Types

type Config

type Config struct {
	Level         zap.AtomicLevel       `json:"level"`
	Sink          lumberjack.Logger     `json:"sink"`
	Encoding      string                `json:"encoding"`
	EncoderConfig zapcore.EncoderConfig `json:"encoderConfig"`
	// Whether to use diffCore
	DiffCore      bool `json:"diffCore"`
	DiffCacheSize int  `json:"diffCacheSize"`
	GlogMux       bool `json:"glogMux"`
}

Config configs for zap logger

func LoadConfig

func LoadConfig(bs []byte) (*Config, error)

LoadConfig load config

func LoadConfigFile

func LoadConfigFile(f string) (*Config, error)

LoadConfigFile load config from file

func (*Config) Build

func (cfg *Config) Build(opts ...zap.Option) (*zap.Logger, error)

Build constructs a logger from the Config and Options.

type LogMux

type LogMux interface {
	Write(lvl zapcore.Level, b []byte)
}

LogMux receives log messages

type Option

type Option func(*diffCore)

Option options to set diffCore

func EnableGlogMux

func EnableGlogMux() Option

EnableGlogMux enable glog mux

Jump to

Keyboard shortcuts

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