log

package
v0.0.0-...-0820d52 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2019 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package log redirects output from the standard library's package-global logger to the wrapped zap logger at InfoLevel. It also has a predefined 'standard' Logger accessible through helper functions Print[f|ln], Fatal[f|ln], and Panic[f|ln], which are easier to use than creating a Logger manually.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Err

func Err(err error) zapcore.Field

Err constructs a "error" field with the error text.

func Error

func Error(msg string, fields ...zapcore.Field)

Error logs a message at ErrorLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

func Fatal

func Fatal(args ...interface{})

Fatal is equivalent to Print() followed by a call to os.Exit(1).

func Fatalf

func Fatalf(template string, args ...interface{})

Fatalf is equivalent to Printf() followed by a call to os.Exit(1).

func Fatalln

func Fatalln(args ...interface{})

Fatalln is equivalent to Println() followed by a call to os.Exit(1).

func Info

func Info(msg string, fields ...zapcore.Field)

Info logs a message at InfoLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

func NewDevelopment

func NewDevelopment() *zap.Logger

NewDevelopment creates logger for development

func NewProduction

func NewProduction() *zap.Logger

NewProduction creates logger for production

func Panic

func Panic(args ...interface{})

Panic is equivalent to Print() followed by a call to panic().

func Panicf

func Panicf(template string, args ...interface{})

Panicf is equivalent to Printf() followed by a call to panic().

func Panicln

func Panicln(args ...interface{})

Panicln is equivalent to Println() followed by a call to panic().

func Print

func Print(args ...interface{})

Print calls log.Output to print to the logger. Arguments are handled in the manner of fmt.Printf.

func Printf

func Printf(template string, args ...interface{})

Printf calls log.Output to print to the logger. Arguments are handled in the manner of fmt.Printf.

func Println

func Println(args ...interface{})

Println calls log.Output to print to the logger. Arguments are handled in the manner of fmt.Println.

func ReplaceGlobals

func ReplaceGlobals(l *zap.Logger)

ReplaceGlobals replaces the global loggers

func StdLogger

func StdLogger() (l *log.Logger)

StdLogger returns a *log.Logger which writes to the underlying logger at InfoLevel.

func Sync

func Sync() error

Sync flushes any buffered log entries. Applications should take care to call Sync before exiting.

func Warn

func Warn(msg string, fields ...zapcore.Field)

Warn logs a message at WarnLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

Types

type Logger

type Logger zap.Logger

Logger extends zap.Logger

func With

func With(fields ...zapcore.Field) *Logger

With creates a child logger and adds structured context to it. Fields added to the child don't affect the parent, and vice versa.

Jump to

Keyboard shortcuts

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