log4go

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2019 License: MIT Imports: 14 Imported by: 19

README

log4go

log4go

go get github.com/flywithbug/log4go

func SetLog() {
	w := log.NewFileWriter()
	w.SetPathPattern("./log/log-%Y%M%D.log")
	c := log.NewConsoleWriter()
	c.SetColor(true)
	log.Register(w)
	log.Register(c)
	log.SetLevel(log.DEBUG)
	log.SetLayout("2006-01-02 15:04:05")
}
log4go.Warn(err.Error())
log4go.Info("info need log")

log4go

Documentation

Index

Constants

View Source
const (
	DEBUG = iota
	INFO
	NEVERShow
	WARNING
	ERROR
	FATAL
)

Variables

View Source
var (
	LEVEL_FLAGS = [...]string{"DEBUG", "INFO", "NEVERShow", "WARN", "ERROR", "FATAL"}
)

Functions

func Close

func Close()

func Debug

func Debug(args ...interface{})

func DebugExtF

func DebugExtF(ext interface{}, fmt string, args ...interface{})

func DebugF

func DebugF(fmt string, args ...interface{})

func Error

func Error(args ...interface{})

func ErrorExtF

func ErrorExtF(ext interface{}, fmt string, args ...interface{})

func ErrorF

func ErrorF(fmt string, args ...interface{})

func Fatal

func Fatal(args ...interface{})

func FatalExtF

func FatalExtF(ext interface{}, fmt string, args ...interface{})

func FatalF

func FatalF(fmt string, args ...interface{})

func Info

func Info(args ...interface{})

func InfoExtF

func InfoExtF(ext interface{}, fmt string, args ...interface{})

func InfoF

func InfoF(fmt string, args ...interface{})

func InfoFNL

func InfoFNL(fmt string, args ...interface{})

func NeverShowF

func NeverShowF(ext interface{}, fmt string, args ...interface{})

func Register

func Register(w Writer)

func SetLayout

func SetLayout(layout string)

func SetLevel

func SetLevel(lvl int)

func SetupLogWithConf

func SetupLogWithConf(file string) (err error)

func Warn

func Warn(args ...interface{})

func WarnExtF

func WarnExtF(ext interface{}, fmt string, args ...interface{})

func WarnF

func WarnF(fmt string, args ...interface{})

Types

type ConfConsoleWriter

type ConfConsoleWriter struct {
	On    bool `json:"On"`
	Color bool `json:"Color"`
}

type ConfFileWriter

type ConfFileWriter struct {
	LogPath string `json:"LogPath"`
	On      bool   `json:"On"`
}

type ConsoleWriter

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

func NewConsoleWriter

func NewConsoleWriter() *ConsoleWriter

func (*ConsoleWriter) Init

func (w *ConsoleWriter) Init() error

func (*ConsoleWriter) SetColor

func (w *ConsoleWriter) SetColor(c bool)

func (*ConsoleWriter) Write

func (w *ConsoleWriter) Write(r *Record) error

type FileWriter

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

func NewFileWriter

func NewFileWriter() *FileWriter

func (*FileWriter) Flush

func (w *FileWriter) Flush() error

func (*FileWriter) Init

func (w *FileWriter) Init() error

func (*FileWriter) Rotate

func (w *FileWriter) Rotate() error

func (*FileWriter) SetPathPattern

func (w *FileWriter) SetPathPattern(pattern string) error

func (*FileWriter) Write

func (w *FileWriter) Write(r *Record) error

type Flusher

type Flusher interface {
	Flush() error
}

type LogConfig

type LogConfig struct {
	Level  string            `json:"LogLevel"`
	FW     ConfFileWriter    `json:"FileWriter"`
	CW     ConfConsoleWriter `json:"ConsoleWriter"`
	Layout string            `json:"Layout"`
}

type Logger

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

func NewLogger

func NewLogger() *Logger

func (*Logger) Close

func (l *Logger) Close()

func (*Logger) DebugF

func (l *Logger) DebugF(fmt string, args ...interface{})

func (*Logger) ErrorF

func (l *Logger) ErrorF(fmt string, args ...interface{})

func (*Logger) FatalF

func (l *Logger) FatalF(fmt string, args ...interface{})

func (*Logger) InfoF

func (l *Logger) InfoF(fmt string, args ...interface{})

func (*Logger) InfoFNL

func (l *Logger) InfoFNL(fmt string, args ...interface{})

func (*Logger) Register

func (l *Logger) Register(w Writer)

func (*Logger) SetLayout

func (l *Logger) SetLayout(layout string)

func (*Logger) SetLevel

func (l *Logger) SetLevel(lvl int)

func (*Logger) WarnF

func (l *Logger) WarnF(fmt string, args ...interface{})

type LoggerCallbackFunc

type LoggerCallbackFunc func(record Record)

type Record

type Record struct {
	Time  string
	Code  string
	Info  string
	Level int
	Ext   interface{}
}

func (*Record) String

func (r *Record) String() string

type Rotater

type Rotater interface {
	Rotate() error
	SetPathPattern(string) error
}

type Writer

type Writer interface {
	Init() error
	Write(*Record) error
}

Jump to

Keyboard shortcuts

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