Documentation
¶
Index ¶
- Variables
- func CloseLogFile()
- func CreateFullLog(l *ToLog)
- func SetLogChannelSize(size int)
- func SetLogFileDateFormat(format DateFormat)
- func SetLogPrefix(prefix string)
- func SetLogTickerTime(duration time.Duration)
- func SetLogTimeFormat(format DateFormat)
- func SetLogTimeZone(zone *time.Location)
- func SetLogWithColor(flag bool)
- type DateFormat
- type LogStatus
- type Options
- type ToLog
- func Debug(ctx string) *ToLog
- func Debugf(format string, a ...any) *ToLog
- func Debugln(a ...any) *ToLog
- func Error(ctx string) *ToLog
- func Errorf(format string, a ...any) *ToLog
- func Errorln(a ...any) *ToLog
- func Info(ctx string) *ToLog
- func Infof(format string, a ...any) *ToLog
- func Infoln(a ...any) *ToLog
- func Log(options ...Options) *ToLog
- func Notice(ctx string) *ToLog
- func Noticef(format string, a ...any) *ToLog
- func Noticeln(a ...any) *ToLog
- func Warning(ctx string) *ToLog
- func Warningf(format string, a ...any) *ToLog
- func Warningln(a ...any) *ToLog
Constants ¶
This section is empty.
Variables ¶
var LogTimeZone = time.Local
LogTimeZone The time zoon logger will print time at. Default is Local.
var LogWithColor = true
LogWithColor The variable of whether to use color in the log, default is true.
var LogfilePrefix = ""
LogfilePrefix The prefix of the log file, default is null. Use set prefix to set.
Functions ¶
func CreateFullLog ¶
func CreateFullLog(l *ToLog)
CreateFullLog creates the full log message by combining log time, type, and context.
func SetLogChannelSize ¶
func SetLogChannelSize(size int)
SetLogChannelSize set the size of go channel for cache.
func SetLogFileDateFormat ¶
func SetLogFileDateFormat(format DateFormat)
SetLogFileDateFormat sets the date format for log file.
func SetLogTickerTime ¶
SetLogTickerTime set the duration of saving log to file.
func SetLogTimeFormat ¶
func SetLogTimeFormat(format DateFormat)
SetLogTimeFormat sets the date format for log time.
func SetLogTimeZone ¶ added in v1.0.3
SetLogTimeZone sets the time zone for log time.
func SetLogWithColor ¶
func SetLogWithColor(flag bool)
SetLogWithColor sets the log shows colors or not.
Types ¶
type DateFormat ¶
type DateFormat string
const ( Layout DateFormat = "01/02 03:04:05PM '06 -0700" // The reference time, in numerical order. ANSIC DateFormat = "Mon Jan _2 15:04:05 2006" UnixDate DateFormat = "Mon Jan _2 15:04:05 MST 2006" RubyDate DateFormat = "Mon Jan 02 15:04:05 -0700 2006" RFC822 DateFormat = "02 Jan 06 15:04 MST" RFC822Z DateFormat = "02 Jan 06 15:04 -0700" // RFC822 with numeric zone RFC850 DateFormat = "Monday, 02-Jan-06 15:04:05 MST" RFC1123 DateFormat = "Mon, 02 Jan 2006 15:04:05 MST" RFC1123Z DateFormat = "Mon, 02 Jan 2006 15:04:05 -0700" // RFC1123 with numeric zone RFC3339 DateFormat = "2006-01-02T15:04:05Z07:00" RFC3339Nano DateFormat = "2006-01-02T15:04:05.999999999Z07:00" Kitchen DateFormat = "3:04PM" // Handy time stamps. Stamp DateFormat = "Jan _2 15:04:05" StampMilli DateFormat = "Jan _2 15:04:05.000" StampMicro DateFormat = "Jan _2 15:04:05.000000" StampNano DateFormat = "Jan _2 15:04:05.000000000" DateTime DateFormat = "2006-01-02 15:04:05" DateOnly DateFormat = "2006-01-02" TimeOnly DateFormat = "15:04:05" )
type Options ¶
type Options func(l *ToLog)
Options is a function type for specifying log options using functional options pattern.
func WithContext ¶
WithContext sets the log context using functional options.
type ToLog ¶
type ToLog struct {
FullLog string
// contains filtered or unexported fields
}
ToLog represents a log entry with various attributes.
func Debug ¶
Debug sets the log type to "debug" and sets the log context for an existing ToLog instance.
func Debugf ¶
Debugf sets the log type to "debug" and sets the formatted log context for an existing ToLog instance.
func Debugln ¶
Debugln sets the log type to "debug" and sets the log context with a newline for an existing ToLog instance.
func Error ¶
Error sets the log type to "error" and sets the log context for an existing ToLog instance.
func Errorf ¶
Errorf sets the log type to "error" and sets the formatted log context for an existing ToLog instance.
func Errorln ¶
Errorln sets the log type to "error" and sets the log context with a newline for an existing ToLog instance.
func Info ¶
Info sets the log type to "info" and sets the log context for an existing ToLog instance.
func Infof ¶
Infof sets the log type to "info" and sets the formatted log context for an existing ToLog instance.
func Infoln ¶
Infoln sets the log type to "info" and sets the log context with a newline for an existing ToLog instance.
func Notice ¶
Notice sets the log type to "notice" and sets the log context for an existing ToLog instance.
func Noticef ¶
Noticef sets the log type to "notice" and sets the formatted log context for an existing ToLog instance.
func Noticeln ¶
Noticeln sets the log type to "notice" and sets the log context with a newline for an existing ToLog instance.
func Warning ¶
Warning sets the log type to "warning" and sets the log context for an existing ToLog instance.
func Warningf ¶
Warningf sets the log type to "warning" and sets the formatted log context for an existing ToLog instance.
func Warningln ¶
Warningln sets the log type to "warning" and sets the log context with a newline for an existing ToLog instance.
func (*ToLog) PrintAndWrite
deprecated
func (l *ToLog) PrintAndWrite()
Deprecated: PrintAndWriteSafe instead
func (*ToLog) PrintAndWriteSafe ¶
func (l *ToLog) PrintAndWriteSafe()
func (*ToLog) PrintLog ¶
PrintLog prints the full log to the console for an existing ToLog instance.