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 CustomLogf ¶
CustomLogf outputs formatted custom level 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 ReplaceExitFunc ¶ added in v1.2.7
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
Types ¶
type Glg ¶
type Glg struct {
// contains filtered or unexported fields
}
Glg is glg base struct
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) CustomLogf ¶
CustomLogf outputs formatted custom level log
func (*Glg) DisableLevelColor ¶
DisableLevelColor disables color output
func (*Glg) EnableLevelColor ¶
EnableLevelColor enables color output
func (*Glg) Fatal ¶
func (g *Glg) Fatal(val ...interface{})
Fatal outputs 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) 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) TagStringToLevel ¶
TagStringToLevel converts level string to Glg.LEVEL
type LEVEL ¶
type LEVEL uint8
LEVEL is log level
func TagStringToLevel ¶
TagStringToLevel converts level string to glg.LEVEL