log

package
v0.2.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2018 License: Apache-2.0 Imports: 7 Imported by: 223

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(a ...interface{})

Error logs to the ERROR logs. Arguments are handled in the manner of fmt.Print; a newline is appended if missing.

func Errorf

func Errorf(format string, a ...interface{})

Errorf logs to the ERROR logs. Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.

func Errorln

func Errorln(a ...interface{})

Errorln logs to the ERROR logs. Arguments are handled in the manner of fmt.Println; a newline is appended if missing.

func Fatal

func Fatal(a ...interface{})

Fatal logs to the FATAL logs, then calls os.Exit(1). Arguments are handled in the manner of fmt.Print; a newline is appended if missing.

func Fatalf

func Fatalf(format string, a ...interface{})

Fatalf logs to the FATAL logs, then calls os.Exit(1). Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.

func Fatalln

func Fatalln(a ...interface{})

Fatalln logs to the FATAL logs, then calls os.Exit(1). Arguments are handled in the manner of fmt.Println; a newline is appended if missing.

func Info

func Info(a ...interface{})

Info logs to the INFO log. Arguments are handled in the manner of fmt.Println; a newline is appended if missing.

func Infof

func Infof(format string, a ...interface{})

Infof logs to the INFO log. Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.

func Infoln

func Infoln(a ...interface{})

Infoln logs to the INFO log. Arguments are handled in the manner of fmt.Println; a newline is appended if missing.

func SetDefaultLogger

func SetDefaultLogger(l Logger)

SetDefaultLogger sets default logger.

func Warning

func Warning(a ...interface{})

Warning logs to the WARNING logs. Arguments are handled in the manner of fmt.Print; a newline is appended if missing.

func Warningf

func Warningf(format string, a ...interface{})

Warningf logs to the WARNING logs. Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.

func Warningln

func Warningln(a ...interface{})

Warningln logs to the WARNING logs. Arguments are handled in the manner of fmt.Println; a newline is appended if missing.

Types

type Level

type Level int32

Level is log level of verboser. We strongly recommend you to follow the rules: 1. Use LevelDebug for debug log. 2. Use 1 for important but not frequent log. 3. Use 2 for important and frequent log. 4. Use 3 for not important and not frequent log. 5. Use 4 for not important but frequent log. 6. Use [5, LevelDebug) only if you want to custom log levels.

const (
	// LevelDebug is for debug info.
	LevelDebug Level = math.MaxInt32
)

type Logger

type Logger interface {
	Verboser
	// V reports whether verbosity at the call site is at least the requested level.
	// The returned value is a Verboser, which implements Info, Infof
	// and Infoln. These methods will write to the Info log if called.
	V(Level) Verboser
	// Warning logs to the WARNING logs.
	// Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
	Warning(...interface{})
	// Warningf logs to the WARNING logs.
	// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
	Warningf(string, ...interface{})
	// Warningln logs to the WARNING logs.
	// Arguments are handled in the manner of fmt.Println; a newline is appended if missing.
	Warningln(...interface{})
	// Error logs to the ERROR logs.
	// Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
	Error(...interface{})
	// Errorf logs to the ERROR logs.
	// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
	Errorf(string, ...interface{})
	// Errorln logs to the ERROR logs.
	// Arguments are handled in the manner of fmt.Println; a newline is appended if missing.
	Errorln(...interface{})
	// Fatal logs to the FATAL logs, then calls os.Exit(1).
	// Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
	Fatal(...interface{})
	// Fatalf logs to the FATAL logs, then calls os.Exit(1).
	// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
	Fatalf(string, ...interface{})
	// Fatalln logs to the FATAL logs, then calls os.Exit(1).
	// Arguments are handled in the manner of fmt.Println; a newline is appended if missing.
	Fatalln(...interface{})
	// Clone clones current logger with new wrapper.
	// A positive wrapper indicates how many wrappers outside the logger.
	// A negative wrapper indicates how many wrappers should be stripped.
	Clone(wrapper int) Logger
}

Logger provides a set of methods to output log.

func DefaultLogger

func DefaultLogger() Logger

DefaultLogger returns default logger.

func NewStdLogger

func NewStdLogger(level Level) Logger

NewStdLogger creates a stdandard logger for logging to stderr.

type Severity

type Severity string

Severity has four classes to correspond with log situation.

const (
	// SeverityInfo is for usual log.
	SeverityInfo Severity = "INFO"
	// SeverityWarning is for warning.
	SeverityWarning Severity = "WARN"
	// SeverityError is for error.
	SeverityError Severity = "ERROR"
	// SeverityFatal is for panic error. The severity means that
	// a logger will output the error and exit immediately.
	// It can't be recovered.
	SeverityFatal Severity = "FATAL"
)

type SilentLogger

type SilentLogger struct{}

SilentLogger logs nothing.

func (*SilentLogger) Clone

func (l *SilentLogger) Clone(wrapper int) Logger

Clone clones current logger with new wrapper. A positive wrapper indicates how many wrappers outside the logger.

func (*SilentLogger) Error

func (*SilentLogger) Error(...interface{})

Error logs to the ERROR logs. Arguments are handled in the manner of fmt.Print; a newline is appended if missing.

func (*SilentLogger) Errorf

func (*SilentLogger) Errorf(string, ...interface{})

Errorf logs to the ERROR logs. Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.

func (*SilentLogger) Errorln

func (*SilentLogger) Errorln(...interface{})

Errorln logs to the ERROR logs. Arguments are handled in the manner of fmt.Println; a newline is appended if missing.

func (*SilentLogger) Fatal

func (*SilentLogger) Fatal(v ...interface{})

Fatal logs to the FATAL logs, then calls os.Exit(1). Arguments are handled in the manner of fmt.Print; a newline is appended if missing.

func (*SilentLogger) Fatalf

func (*SilentLogger) Fatalf(string, ...interface{})

Fatalf logs to the FATAL logs, then calls os.Exit(1). Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.

func (*SilentLogger) Fatalln

func (*SilentLogger) Fatalln(v ...interface{})

Fatalln logs to the FATAL logs, then calls os.Exit(1). Arguments are handled in the manner of fmt.Println; a newline is appended if missing.

func (*SilentLogger) Info

func (*SilentLogger) Info(...interface{})

Info logs to the INFO log. Arguments are handled in the manner of fmt.Println; a newline is appended if missing.

func (*SilentLogger) Infof

func (*SilentLogger) Infof(string, ...interface{})

Infof logs to the INFO log. Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.

func (*SilentLogger) Infoln

func (*SilentLogger) Infoln(...interface{})

Infoln logs to the INFO log. Arguments are handled in the manner of fmt.Println; a newline is appended if missing.

func (*SilentLogger) V

func (l *SilentLogger) V(Level) Verboser

V reports whether verbosity at the call site is at least the requested level. The returned value is a Verboser, which implements Info, Infof

func (*SilentLogger) Warning

func (*SilentLogger) Warning(...interface{})

Warning logs to the WARNING logs. Arguments are handled in the manner of fmt.Print; a newline is appended if missing.

func (*SilentLogger) Warningf

func (*SilentLogger) Warningf(string, ...interface{})

Warningf logs to the WARNING logs. Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.

func (*SilentLogger) Warningln

func (*SilentLogger) Warningln(...interface{})

Warningln logs to the WARNING logs. Arguments are handled in the manner of fmt.Println; a newline is appended if missing.

type Verboser

type Verboser interface {
	// Info logs to the INFO log.
	// Arguments are handled in the manner of fmt.Println; a newline is appended if missing.
	Info(...interface{})
	// Infof logs to the INFO log.
	// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
	Infof(string, ...interface{})
	// Infoln logs to the INFO log.
	// Arguments are handled in the manner of fmt.Println; a newline is appended if missing.
	Infoln(...interface{})
}

Verboser is an interface type that implements Info(f|ln) . See the documentation of V for more information.

func V

func V(v Level) Verboser

V reports whether verbosity at the call site is at least the requested level. The returned value is a Verboser, which implements Info, Infof and Infoln. These methods will write to the Info log if called.

Jump to

Keyboard shortcuts

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