zap

package
v0.0.0-...-e5f04d6 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 7 Imported by: 0

README

zap

1. 配置

// 添加配置
log:
  level: info
  format: console
  director: ./log
  show-line: true
  encode-level: LowercaseColorLevelEncoder
  stacktrace-key: stacktrace
  log-in-console: true

2. 代码

1. 读取配置
import "github.com/Baal19905/playground/pkg/log/zap"

// 在配置中添加zap对象
type Config struct {
    // ...
    Log        zap.Config            `mapstructure:"log"`
    // ...
}

// load config
2. 使用db
import "github.com/Baal19905/playground/pkg/log/zap"

// 初始化指标
func (j *job) Init() {
    // ...
    j.logger = zap.NewZap(config)
    // ...
}

// 记录指标
func (j *job) Run() {
    // ...
    j.logger.Info("log")
    // ...
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetWriteSyncer

func GetWriteSyncer(z Config) (zapcore.WriteSyncer, error)

Types

type Config

type Config struct {
	Level         string `mapstructure:"level"`
	Format        string `mapstructure:"format"`
	Director      string `mapstructure:"director"`
	LinkName      string `mapstructure:"link-name"`
	ShowLine      bool   `mapstructure:"show-line"`
	EncodeLevel   string `mapstructure:"encode-level"`
	StacktraceKey string `mapstructure:"stacktrace-key"`
	LogInConsole  bool   `mapstructure:"log-in-console"`
}

type Zap

type Zap struct {
	*zap.Logger
}

func NewZap

func NewZap(z Config) *Zap

Jump to

Keyboard shortcuts

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