zapkit

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2022 License: MIT Imports: 7 Imported by: 0

README

## app.ini
# zapkit
zapkit.file = "/tmp/zapkit.log"
zapkit.level = "debug"
zapkit.maxsize = 256
zapkit.maxbackups = 20
zapkit.maxage = 7
zapkit.compress = false


## golang
import(
    "common/modules/zapkit"

    "go.uber.org/zap"
)

// 初始化日志模块
log.Init()
defer log.Sync()

log.Debug("ipquery", zap.Int("IPQuery", IPQuery))
log.Info("hit hosts file", zap.String("domain", Q.qname), zap.String("answer", h.AnswerToString(m.Answer)))

log.Infof("abc: %s", name)

Documentation

Index

Constants

View Source
const (
	LevelDebug = iota
	LevelInfo
	LevelWarn
	LevelError
	LevelNone
)

Variables

View Source
var LoggerLevel = map[string]int{
	"debug": LevelDebug,
	"info":  LevelInfo,
	"warn":  LevelWarn,
	"error": LevelError,
	"none":  LevelNone,
}

Functions

func Debug

func Debug(str string, args ...zap.Field)

func Debugf

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

func Error

func Error(str string, args ...zap.Field)

func Errorf

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

func Info

func Info(str string, args ...zap.Field)

func Infof

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

func Init

func Init(zapCfg *ZapkitConfig, args ...string) error

初始化方法

func Sync

func Sync() error

func ThirdInit

func ThirdInit(logPath, logLevel string) error

func Warn

func Warn(str string, args ...zap.Field)

func Warnf

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

Types

type Logkit

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

type ZapkitConfig

type ZapkitConfig struct {
	File       string `yaml:"file"`
	Level      string `yaml:"level"`
	MaxSize    int    `yaml:"maxsize"`
	MaxBackups int    `yaml:"maxbackups"`
	MaxAge     int    `yaml:"maxage"`
	Compress   bool   `yaml:"compress"`
}

Jump to

Keyboard shortcuts

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