log

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCallerDepth = 2
)

Variables

View Source
var (
	FatalLevel = logLevel{1, " [FATAL] "}
	ErrorLevel = logLevel{2, " [ERROR] "}
	WarnLevel  = logLevel{3, " [WARN]  "}
	InfoLevel  = logLevel{4, " [INFO]  "}
	DebugLevel = logLevel{5, " [DEBUG] "}
)

Functions

func Debug

func Debug(v ...interface{})

Debug print logs like log.Print, but has a prefix with "[DEBUG]"

func Debugf

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

Debugf print logs like log.Printf, but has a prefix with "[DEBUG]"

func Error

func Error(v ...interface{})

Error print logs like log.Print, but has a prefix with "[ERROR]"

func Errorf

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

Errorf print logs like log.Printf, but has a prefix with "[ERROR]"

func Fatal

func Fatal(v ...interface{})

Fatal print logs like log.Print, but has a prefix with "[FATAL]"

func Fatalf

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

Fatalf print logs like log.Printf, but has a prefix with "[FATAL]"

func Info

func Info(v ...interface{})

Info print logs like log.Print, but has a prefix with "[INFO]"

func Infof

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

Infof print logs like log.Printf, but has a prefix with "[INFO]"

func SetLogLevel

func SetLogLevel(level logLevel)

SetLogLevel set current log level, only the higher level log will be written to the file

func Warn

func Warn(v ...interface{})

Warn print logs like log.Print, but has a prefix with "[WARN]"

func Warnf

func Warnf(foramt string, v ...interface{})

Warnf print logs like log.Printf, but has a prefix with "[WARN]"

Types

type FileHandler

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

func NewFileHandler

func NewFileHandler(filename string) *FileHandler

func (*FileHandler) Close

func (handler *FileHandler) Close() error

func (*FileHandler) Flush

func (handler *FileHandler) Flush() error

func (*FileHandler) Writer

func (handler *FileHandler) Writer() io.Writer

type Handler

type Handler interface {
	Writer() io.Writer
	Close() error
	Flush() error
}

type Logger

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

func NewLogger

func NewLogger(name string) *Logger

func (*Logger) AddHandler

func (logger *Logger) AddHandler(handler Handler) *Logger

func (*Logger) Close

func (logger *Logger) Close() error

func (*Logger) Record

func (logger *Logger) Record(record ...interface{}) error

type RotatingFileHandler

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

func NewRotatingFileHandler

func NewRotatingFileHandler(filename string) *RotatingFileHandler

func (*RotatingFileHandler) Close

func (handler *RotatingFileHandler) Close() error

func (*RotatingFileHandler) Flush

func (handler *RotatingFileHandler) Flush() error

func (*RotatingFileHandler) SetDateFormat

func (handler *RotatingFileHandler) SetDateFormat(f string) *RotatingFileHandler

func (*RotatingFileHandler) Writer

func (handler *RotatingFileHandler) Writer() io.Writer

type StdoutHandler

type StdoutHandler struct {
}

func NewStdoutHandler

func NewStdoutHandler() *StdoutHandler

func (*StdoutHandler) Close

func (handler *StdoutHandler) Close() error

func (*StdoutHandler) Flush

func (handlere *StdoutHandler) Flush() error

func (*StdoutHandler) Writer

func (handler *StdoutHandler) Writer() io.Writer

Jump to

Keyboard shortcuts

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