Documentation
¶
Overview ¶
Package glg can quickly output that are colored and leveled logs with simple syntax
Index ¶
- Constants
- func Black(str string) string
- func Brown(str string) string
- func Colorless(str string) string
- func CustomLog(level string, val ...interface{}) error
- func CustomLogf(level string, format string, val ...interface{}) error
- func Cyan(str string) string
- func Debug(val ...interface{}) error
- func Debugf(format string, val ...interface{}) error
- func Error(val ...interface{}) error
- func Errorf(format string, val ...interface{}) error
- func Fail(val ...interface{}) error
- func Failf(format string, val ...interface{}) error
- func Fatal(val ...interface{})
- func Fatalf(format string, val ...interface{})
- func Fatalln(val ...interface{})
- func FileWriter(path string, perm os.FileMode) *os.File
- func Gray(str string) string
- func Green(str string) string
- func HTTPLogger(name string, handler http.Handler) http.Handler
- func HTTPLoggerFunc(name string, hf http.HandlerFunc) http.Handler
- func Info(val ...interface{}) error
- func Infof(format string, val ...interface{}) error
- func Log(val ...interface{}) error
- func Logf(format string, val ...interface{}) error
- func Orange(str string) string
- func Print(val ...interface{}) error
- func Printf(format string, val ...interface{}) error
- func Println(val ...interface{}) error
- func Purple(str string) string
- func RawString(data []byte) string
- func Red(str string) string
- func ReplaceExitFunc(fn func(i int))
- func Success(val ...interface{}) error
- func Successf(format string, val ...interface{}) error
- func Warn(val ...interface{}) error
- func Warnf(format string, val ...interface{}) error
- func White(str string) string
- func Yellow(str string) string
- type Glg
- func (g *Glg) AddErrLevel(tag string, mode MODE, isColor bool) *Glg
- func (g *Glg) AddLevelWriter(level LEVEL, writer io.Writer) *Glg
- func (g *Glg) AddStdLevel(tag string, mode MODE, isColor bool) *Glg
- func (g *Glg) AddWriter(writer io.Writer) *Glg
- func (g *Glg) CustomLog(level string, val ...interface{}) error
- func (g *Glg) CustomLogf(level string, format string, val ...interface{}) error
- func (g *Glg) Debug(val ...interface{}) error
- func (g *Glg) Debugf(format string, val ...interface{}) error
- func (g *Glg) DisableColor() *Glg
- func (g *Glg) DisableLevelColor(lv LEVEL) *Glg
- func (g *Glg) EnableColor() *Glg
- func (g *Glg) EnableLevelColor(lv LEVEL) *Glg
- func (g *Glg) Error(val ...interface{}) error
- func (g *Glg) Errorf(format string, val ...interface{}) error
- func (g *Glg) Fail(val ...interface{}) error
- func (g *Glg) Failf(format string, val ...interface{}) error
- func (g *Glg) Fatal(val ...interface{})
- func (g *Glg) Fatalf(format string, val ...interface{})
- func (g *Glg) Fatalln(val ...interface{})
- func (g *Glg) GetCurrentMode(level LEVEL) MODE
- func (g *Glg) HTTPLogger(name string, handler http.Handler) http.Handler
- func (g *Glg) HTTPLoggerFunc(name string, hf http.HandlerFunc) http.Handler
- func (g *Glg) Info(val ...interface{}) error
- func (g *Glg) Infof(format string, val ...interface{}) error
- func (g *Glg) InitWriter() *Glg
- func (g *Glg) Log(val ...interface{}) error
- func (g *Glg) Logf(format string, val ...interface{}) error
- func (g *Glg) Print(val ...interface{}) error
- func (g *Glg) Printf(format string, val ...interface{}) error
- func (g *Glg) Println(val ...interface{}) error
- func (g *Glg) RawString(data []byte) string
- func (g *Glg) Reset() *Glg
- func (g *Glg) SetLevelColor(level LEVEL, color func(string) string) *Glg
- func (g *Glg) SetLevelMode(level LEVEL, mode MODE) *Glg
- func (g *Glg) SetLevelWriter(level LEVEL, writer io.Writer) *Glg
- func (g *Glg) SetMode(mode MODE) *Glg
- func (g *Glg) SetPrefix(pref string) *Glg
- func (g *Glg) SetWriter(writer io.Writer) *Glg
- func (g *Glg) Success(val ...interface{}) error
- func (g *Glg) Successf(format string, val ...interface{}) error
- func (g *Glg) TagStringToLevel(tag string) LEVEL
- func (g *Glg) Warn(val ...interface{}) error
- func (g *Glg) Warnf(format string, val ...interface{}) error
- type LEVEL
- type MODE
Constants ¶
const ( // LOG is log level LOG LEVEL = iota // PRINT is print log level PRINT // INFO is info log level INFO // DEBG is debug log level DEBG // OK is success notify log level OK // WARN is warning log level WARN // ERR is error log level ERR // FAIL is failed log level FAIL // FATAL is fatal log level FATAL // NONE is disable Logging NONE MODE = iota // STD is std log mode STD // BOTH is both log mode BOTH // WRITER is io.Writer log mode WRITER )
Variables ¶
This section is empty.
Functions ¶
func CustomLog ¶
CustomLog outputs custom level log
func CustomLogf ¶
CustomLogf outputs formatted custom level log
func Debugf ¶
Debugf outputs formatted Debug level log
func Errorf ¶
Errorf outputs formatted Error log
func Fatalf ¶
func Fatalf(format string, val ...interface{})
Fatalf outputs formatted Failed log and exit program
func Fatalln ¶
func Fatalln(val ...interface{})
Fatalln outputs line fixed Failed log and exit program
func FileWriter ¶
FileWriter generates *osFile -> io.Writer
func HTTPLogger ¶
HTTPLogger is simple http access logger
func HTTPLoggerFunc ¶
func HTTPLoggerFunc(name string, hf http.HandlerFunc) http.Handler
HTTPLoggerFunc is simple http access logger
func Infof ¶
Infof outputs formatted Info level log
func Logf ¶
Logf writes std log event with format
func Printf ¶
Printf outputs formatted Print log
func RawString ¶ added in v1.2.11
RawString returns raw log string exclude time & tags
func ReplaceExitFunc ¶ added in v1.2.11
func ReplaceExitFunc(fn func(i int))
ReplaceExitFunc replaces exit function. If you do not want to start os.Exit at glg.Fatal error, use this function to register arbitrary function
func Successf ¶
Successf outputs formatted Success level log
func Warnf ¶
Warnf outputs formatted Warn level log
Types ¶
type Glg ¶
type Glg struct {
// contains filtered or unexported fields
}
Glg is glg base struct
func SetPrefix ¶ added in v1.2.11
SetPrefix set Print logger prefix
func (*Glg) AddErrLevel ¶
AddErrLevel adds error log level and returns LEVEL
func (*Glg) AddLevelWriter ¶
AddLevelWriter adds writer to glg std writer per logging level
func (*Glg) AddStdLevel ¶
AddStdLevel adds std log level and returns LEVEL
func (*Glg) AddWriter ¶
AddWriter adds writer to glg std writers
func (*Glg) CustomLog ¶
CustomLog outputs custom level log
func (*Glg) CustomLogf ¶
CustomLogf outputs formatted custom level log
func (*Glg) Debugf ¶
Debugf outputs formatted Debug level log
func (*Glg) DisableLevelColor ¶
DisableLevelColor disables color output
func (*Glg) EnableLevelColor ¶
EnableLevelColor enables color output
func (*Glg) Errorf ¶
Errorf outputs formatted Error log
func (*Glg) Failf ¶
Failf outputs formatted Failed log
func (*Glg) Fatal ¶
func (g *Glg) Fatal(val ...interface{})
Fatal outputs Failed log and exit program
func (*Glg) Fatalf ¶
Fatalf outputs formatted Failed log and exit program
func (*Glg) Fatalln ¶
func (g *Glg) Fatalln(val ...interface{})
Fatalln outputs line fixed Failed log and exit program
func (*Glg) GetCurrentMode ¶
GetCurrentMode returns current logging mode
func (*Glg) HTTPLogger ¶
HTTPLogger is simple http access logger
func (*Glg) HTTPLoggerFunc ¶
HTTPLoggerFunc is simple http access logger
func (*Glg) Infof ¶
Infof outputs formatted Info level log
func (*Glg) Logf ¶
Logf writes std log event with format
func (*Glg) Printf ¶
Printf outputs formatted Print log
func (*Glg) Println ¶
Println outputs fixed line Print log
func (*Glg) RawString ¶ added in v1.2.11
RawString returns raw log string exclude time & tags
func (*Glg) Reset ¶ added in v1.2.11
Reset provides parameter reset function for glg struct instance
func (*Glg) SetLevelColor ¶
SetLevelColor sets the color for each level
func (*Glg) SetLevelMode ¶
SetLevelMode set glg logging mode* per level
func (*Glg) SetLevelWriter ¶
SetLevelWriter sets writer to glg std writer per logging level
func (*Glg) SetWriter ¶
SetWriter sets writer to glg std writers
func (*Glg) Success ¶
Success outputs Success level log
func (*Glg) Successf ¶
Successf outputs formatted Success level log
func (*Glg) TagStringToLevel ¶
TagStringToLevel converts level string to Glg.LEVEL
Source Files
¶
- glg.go

