Documentation ¶
Overview ¶
Package glg can quickly output that are colored and leveled logs with simple syntax
Package glg can quickly output that are colored and leveled logs with simple syntax ¶
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 CustomLogFunc(level string, f func() string) error
- func CustomLogf(level string, format string, val ...interface{}) error
- func Cyan(str string) string
- func Debug(val ...interface{}) error
- func DebugFunc(f func() string) error
- func Debugf(format string, val ...interface{}) error
- func Error(val ...interface{}) error
- func ErrorFunc(f func() string) error
- func Errorf(format string, val ...interface{}) error
- func Fail(val ...interface{}) error
- func FailFunc(f func() string) 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 InfoFunc(f func() string) error
- func Infof(format string, val ...interface{}) error
- func Log(val ...interface{}) error
- func LogFunc(f func() string) error
- func Logf(format string, val ...interface{}) error
- func Orange(str string) string
- func Print(val ...interface{}) error
- func PrintFunc(f func() string) 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 SuccessFunc(f func() string) error
- func Successf(format string, val ...interface{}) error
- func Trace(val ...interface{}) error
- func TraceFunc(f func() string) error
- func Tracef(format string, val ...interface{}) error
- func Warn(val ...interface{}) error
- func WarnFunc(f func() string) 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) Atol(tag string) LEVEL
- func (g *Glg) CustomLog(level string, val ...interface{}) error
- func (g *Glg) CustomLogFunc(level string, f func() string) error
- func (g *Glg) CustomLogf(level string, format string, val ...interface{}) error
- func (g *Glg) Debug(val ...interface{}) error
- func (g *Glg) DebugFunc(f func() string) error
- func (g *Glg) Debugf(format string, val ...interface{}) error
- func (g *Glg) DisableColor() *Glg
- func (g *Glg) DisableJSON() *Glg
- func (g *Glg) DisableLevelColor(lv LEVEL) *Glg
- func (g *Glg) DisableLevelTimestamp(lv LEVEL) *Glg
- func (g *Glg) DisableTimestamp() *Glg
- func (g *Glg) EnableColor() *Glg
- func (g *Glg) EnableJSON() *Glg
- func (g *Glg) EnableLevelColor(lv LEVEL) *Glg
- func (g *Glg) EnableLevelTimestamp(lv LEVEL) *Glg
- func (g *Glg) EnablePoolBuffer(size int) *Glg
- func (g *Glg) EnableTimestamp() *Glg
- func (g *Glg) Error(val ...interface{}) error
- func (g *Glg) ErrorFunc(f func() string) error
- func (g *Glg) Errorf(format string, val ...interface{}) error
- func (g *Glg) Fail(val ...interface{}) error
- func (g *Glg) FailFunc(f func() string) 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) GetTimeLocation() (loc *time.Location)
- 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) InfoFunc(f func() string) 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) LogFunc(f func() string) error
- func (g *Glg) Logf(format string, val ...interface{}) error
- func (g *Glg) Print(val ...interface{}) error
- func (g *Glg) PrintFunc(f func() string) 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) SetCallerDepth(depth int) *Glg
- func (g *Glg) SetLevel(lv LEVEL) *Glg
- func (g *Glg) SetLevelColor(level LEVEL, color func(string) string) *Glg
- func (g *Glg) SetLevelLineTraceMode(lv LEVEL, mode traceMode) *Glg
- func (g *Glg) SetLevelMode(level LEVEL, mode MODE) *Glg
- func (g *Glg) SetLevelWriter(level LEVEL, writer io.Writer) *Glg
- func (g *Glg) SetLineTraceMode(mode traceMode) *Glg
- func (g *Glg) SetMode(mode MODE) *Glg
- func (g *Glg) SetPrefix(lev LEVEL, pref string) *Glg
- func (g *Glg) SetTimeLocation(loc *time.Location) *Glg
- func (g *Glg) SetWriter(writer io.Writer) *Glg
- func (g *Glg) Success(val ...interface{}) error
- func (g *Glg) SuccessFunc(f func() string) error
- func (g *Glg) Successf(format string, val ...interface{}) error
- func (g *Glg) TagStringToLevel(tag string) LEVEL
- func (g *Glg) Trace(val ...interface{}) error
- func (g *Glg) TraceFunc(f func() string) error
- func (g *Glg) Tracef(format string, val ...interface{}) error
- func (g *Glg) Warn(val ...interface{}) error
- func (g *Glg) WarnFunc(f func() string) error
- func (g *Glg) Warnf(format string, val ...interface{}) error
- type JSONFormat
- type LEVEL
- type MODE
Constants ¶
const ( // DEBG is debug log level DEBG LEVEL = iota + 1 // TRACE is trace log level TRACE // PRINT is print log level PRINT // LOG is log level LOG // INFO is info log level INFO // 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 // UNKNOWN is unknown log level UNKNOWN LEVEL = LEVEL(math.MaxUint8) // NONE is disable Logging NONE MODE = iota + 1 // STD is std log mode STD // BOTH is both log mode BOTH // WRITER is io.Writer log mode WRITER TraceLineNone traceMode = 1 << iota TraceLineShort TraceLineLong DefaultCallerDepth = 2 )
Variables ¶
This section is empty.
Functions ¶
func CustomLogFunc ¶ added in v1.3.0
CustomLogFunc outputs custom level log returned from the function
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
func SuccessFunc ¶ added in v1.3.0
SuccessFunc outputs Success level log returned from the function
Types ¶
type Glg ¶
type Glg struct {
// contains filtered or unexported fields
}
Glg is glg base struct
func Reset ¶ added in v1.5.1
func Reset() *Glg
Reset provides parameter reset function for glg struct instance
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) CustomLogFunc ¶ added in v1.3.0
CustomLogFunc outputs custom level log returned from the function
func (*Glg) CustomLogf ¶
CustomLogf outputs formatted custom level log
func (*Glg) DebugFunc ¶ added in v1.3.0
DebugFunc outputs Debug level log returned from the function
func (*Glg) DisableJSON ¶ added in v1.5.0
func (*Glg) DisableLevelColor ¶
DisableLevelColor disables color output
func (*Glg) DisableLevelTimestamp ¶ added in v1.5.6
DisableLevelTimestamp disables timestamp output
func (*Glg) DisableTimestamp ¶ added in v1.5.6
DisableTimestamp disables timestamp output
func (*Glg) EnableJSON ¶ added in v1.5.0
func (*Glg) EnableLevelColor ¶
EnableLevelColor enables color output
func (*Glg) EnableLevelTimestamp ¶ added in v1.5.6
EnableLevelTimestamp enables timestamp output
func (*Glg) EnablePoolBuffer ¶ added in v1.5.0
func (*Glg) EnableTimestamp ¶ added in v1.5.6
EnableTimestamp enables timestamp output
func (*Glg) ErrorFunc ¶ added in v1.3.0
ErrorFunc outputs Error level log returned from the function
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) GetTimeLocation ¶ added in v1.6.14
GetTimeLocation configures specific time location
func (*Glg) HTTPLogger ¶
HTTPLogger is simple http access logger
func (*Glg) HTTPLoggerFunc ¶
HTTPLoggerFunc is simple http access logger
func (*Glg) SetCallerDepth ¶ added in v1.6.3
SetCallerDepth configures output line trace caller depth
func (*Glg) SetLevelColor ¶
SetLevelColor sets the color for each level
func (*Glg) SetLevelLineTraceMode ¶ added in v1.6.2
SetLevelLineTraceMode configures output line traceFlag
func (*Glg) SetLevelMode ¶
SetLevelMode sets glg logging mode* per level
func (*Glg) SetLevelWriter ¶
SetLevelWriter sets writer to glg std writer per logging level
func (*Glg) SetLineTraceMode ¶ added in v1.6.2
SetLineTraceMode configures output line traceFlag
func (*Glg) SetTimeLocation ¶ added in v1.6.14
SetTimeLocation configures specific time location
func (*Glg) SuccessFunc ¶ added in v1.3.0
SuccessFunc outputs Success level log returned from the function
func (*Glg) TagStringToLevel ¶
TagStringToLevel converts level string to Glg.LEVEL
func (*Glg) TraceFunc ¶ added in v1.6.0
TraceFunc outputs Trace level log returned from the function
type JSONFormat ¶ added in v1.5.2
type JSONFormat struct { Date string `json:"date,omitempty"` Level string `json:"level,omitempty"` File string `json:"file,omitempty"` Detail interface{} `json:"detail,omitempty"` }
JSONFormat is json object structure for logging
type LEVEL ¶
type LEVEL uint8
LEVEL is log level
func TagStringToLevel ¶
TagStringToLevel converts level string to glg.LEVEL