Help us shape the future of Go! Take the 2026 Go Developer Survey

zaphelper

package module
v0.0.0-...-f9cf980 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2018 License: MIT Imports: 9 Imported by: 0

README

zaphelper

GoDoc Go Report Card

Tools to help user experience of go.uber.org/zap

TODO

  • Test coverage

Documentation

Overview

Example
InitLogger("/tmp", false, time.Local)
logger := GetLogger("helloworld")
logger.Infow("hello log", "key", "value")
RotateLog()

Index

Examples

Constants

This section is empty.

Variables

View Source
var (

	// Logger zap.Logger实例
	Logger *zap.SugaredLogger
)

Functions

func GetLogger

func GetLogger(name string) *zap.SugaredLogger

GetLogger to get zap.SugaredLogger

func InitLogger

func InitLogger(path string, debugLevel bool, location *time.Location)

InitLogger 初始化 path 输出路径 debugLevel 是否输出debug信息 location 日志文件名所属时区

func RotateLog

func RotateLog()

RotateLog to causes Logger to close the existing log file and immediately create a new one.

Types

type Writer

type Writer struct {
	// Filename is the file to write logs to.  Backup log files will be retained
	// in the same directory.  It uses <processname>-lumberjack.log in
	// os.TempDir() if empty.
	Filename string `json:"filename" yaml:"filename"`
	// contains filtered or unexported fields
}

Writer is an io.WriteCloser that writes to the specified filename.

func (*Writer) Close

func (w *Writer) Close() error

Close implements io.Closer, and closes the current logfile.

func (*Writer) Rotate

func (w *Writer) Rotate() error

Rotate causes Logger to close the existing log file and immediately create a new one. This is a helper function for applications that want to initiate rotations outside of the normal rotation rules, such as in response to SIGHUP.

func (*Writer) Write

func (w *Writer) Write(p []byte) (n int, err error)

Write implements io.Writer.

Jump to

Keyboard shortcuts

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