zlog

package module
v0.0.0-...-6577f27 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2020 License: GPL-3.0 Imports: 6 Imported by: 0

README

zlog

Package zlog provides simple, structured, leveled and rolling logger, based on go.uber.org/zap.

Installation

To install zlog package, you need to install Go and set your Go workspace first.

  1. The first need Go installed (version 1.13+ is required), then you can use the below Go command to install zlog.

    go get -u github.com/mulinbc/zlog
    
  2. Import it in your code:

    import "github.com/mulinbc/zlog"
    

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(filename, level string, maxSize, maxAge, maxBackups, skip int, devMode, localTime, compress bool) (*zap.Logger, error)

New 返回一个 zap.Logger 实例。

Types

type Logger

type Logger struct {
	DevMode    bool   `json:"dev_mode"`
	Level      string `json:"level" validate:"oneof=debug info warn error dpanic panic fatal"`
	Filename   string `json:"filename" validate:"required"`
	MaxSize    int    `json:"max_size" validate:"gte=0"`
	MaxAge     int    `json:"max_age" validate:"gte=0"`
	MaxBackups int    `json:"max_backups" validate:"gte=0"`
	LocalTime  bool   `json:"local_time"`
	Compress   bool   `json:"compress"`
}

Logger 表示 zap.Logger 初始化所需要的参数。

func (*Logger) New

func (p *Logger) New(skip int) (*zap.Logger, error)

New 返回一个 zap.Logger 实例。

Jump to

Keyboard shortcuts

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