log

package
v1.8.6-rc1 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(v ...interface{})

Debug ...

func Debugf

func Debugf(format string, v ...interface{})

Debugf ...

func Error

func Error(v ...interface{})

Error ...

func Errorf

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

Errorf ...

func Fatal

func Fatal(v ...interface{})

Fatal ...

func Fatalf

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

Fatalf ...

func Info

func Info(v ...interface{})

Info ...

func Infof

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

Infof ...

func SetFormatter

func SetFormatter(fmtter Formatter)

SetFormatter sets the formatter of default Logger

func SetLevel

func SetLevel(lvl Level)

SetLevel sets the level of default Logger

func SetOutput

func SetOutput(out io.Writer)

SetOutput sets the output of default Logger

func Warning

func Warning(v ...interface{})

Warning ...

func Warningf

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

Warningf ...

Types

type Formatter

type Formatter interface {
	Format(*Record) ([]byte, error)
}

Formatter formats records in different ways: text, json, etc.

type Level

type Level int

Level ...

const (
	// DebugLevel debug
	DebugLevel Level = iota
	// InfoLevel info
	InfoLevel
	// WarningLevel warning
	WarningLevel
	// ErrorLevel error
	ErrorLevel
	// FatalLevel fatal
	FatalLevel
)

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger provides a struct with fields that describe the details of logger.

func DefaultLogger

func DefaultLogger() *Logger

DefaultLogger returns the default logger within the pkg, i.e. the one used in log.Infof....

func New

func New(out io.Writer, fmtter Formatter, lvl Level, options ...interface{}) *Logger

New returns a customized Logger

func (*Logger) Debug

func (l *Logger) Debug(v ...interface{})

Debug ...

func (*Logger) Debugf

func (l *Logger) Debugf(format string, v ...interface{})

Debugf ...

func (*Logger) Error

func (l *Logger) Error(v ...interface{})

Error ...

func (*Logger) Errorf

func (l *Logger) Errorf(format string, v ...interface{})

Errorf ...

func (*Logger) Fatal

func (l *Logger) Fatal(v ...interface{})

Fatal ...

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, v ...interface{})

Fatalf ...

func (*Logger) Info

func (l *Logger) Info(v ...interface{})

Info ...

func (*Logger) Infof

func (l *Logger) Infof(format string, v ...interface{})

Infof ...

func (*Logger) SetFormatter

func (l *Logger) SetFormatter(fmtter Formatter)

SetFormatter sets the formatter of Logger l

func (*Logger) SetLevel

func (l *Logger) SetLevel(lvl Level)

SetLevel sets the level of Logger l

func (*Logger) SetOutput

func (l *Logger) SetOutput(out io.Writer)

SetOutput sets the output of Logger l

func (*Logger) Warning

func (l *Logger) Warning(v ...interface{})

Warning ...

func (*Logger) Warningf

func (l *Logger) Warningf(format string, v ...interface{})

Warningf ...

type Record

type Record struct {
	Time time.Time // time when the log produced
	Msg  string    // content of the log
	Line string    // in which file and line that the log produced
	Lvl  Level     // level of the log
}

Record holds information about log

func NewRecord

func NewRecord(time time.Time, msg, line string, lvl Level) *Record

NewRecord creates a record according to the arguments provided and returns it

type TextFormatter

type TextFormatter struct {
	// contains filtered or unexported fields
}

TextFormatter represents a kind of formatter that formats the logs as plain text

func NewTextFormatter

func NewTextFormatter() *TextFormatter

NewTextFormatter returns a TextFormatter, the format of time is time.RFC3339

func (*TextFormatter) Format

func (t *TextFormatter) Format(r *Record) (b []byte, err error)

Format formats the logs as "time [level] line message"

func (*TextFormatter) SetTimeFormat

func (t *TextFormatter) SetTimeFormat(fmt string)

SetTimeFormat sets time format of TextFormatter if the parameter fmt is not null

Jump to

Keyboard shortcuts

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