Documentation ¶
Index ¶
- Constants
- func Debugf(format string, args ...interface{}) (int, error)
- func Debugln(args ...interface{}) (int, error)
- func Errorf(format string, args ...interface{}) (int, error)
- func Errorln(args ...interface{}) (int, error)
- func Fatalf(format string, args ...interface{}) (int, error)
- func Fatalln(args ...interface{}) (int, error)
- func GetPrintCallerInfo() bool
- func GetPrintSourceInfo() int8
- func GetStream() io.Writer
- func GetTimeFormat() string
- func Infof(format string, args ...interface{}) (int, error)
- func Infoln(args ...interface{}) (int, error)
- func IsDebug() bool
- func IsDisabled() bool
- func IsError() bool
- func IsFatal() bool
- func IsInfo() bool
- func IsPanic() bool
- func IsTrace() bool
- func IsWarning() bool
- func Panicf(format string, args ...interface{}) (int, error)
- func Panicln(args ...interface{}) (int, error)
- func Printf(format string, args ...interface{}) (int, error)
- func Println(args ...interface{}) (int, error)
- func SetLevel(level LogLevel)
- func SetPrintCallerInfo(enabled bool)
- func SetPrintSourceInfo(value int8)
- func SetStream(stream io.Writer, colorise bool)
- func SetTimeFormat(format string)
- func ToJSON(object interface{}) string
- func Tracef(format string, args ...interface{}) (int, error)
- func Traceln(args ...interface{}) (int, error)
- func Warnf(format string, args ...interface{}) (int, error)
- func Warnln(args ...interface{}) (int, error)
- type Flag
- type LogLevel
Constants ¶
const ( // FlagSourceInfo specifies whether the log message should automatically // include the source location (note: this feature can be computationally // expensive since it uses reflection at runtime). FlagSourceInfo = 1 << iota // FlagFunctionInfo specifies whether the log message should automatically // include the name of the containing function (note: this feature can be // computationally expensive since it uses reflection at runtime). FlagFunctionInfo )
const ( // SourceInfoNone is the constant that specifies that no source file information // (file and line) should be printed out. SourceInfoNone int8 = iota // SourceInfoShort is the constants that specifies that the source file // information should be printed in short form (file name only). SourceInfoShort // SourceInfoLong is the constants that specifies that the source file // information should be printed in log form (complete file path). SourceInfoLong )
Variables ¶
This section is empty.
Functions ¶
func GetPrintCallerInfo ¶
func GetPrintCallerInfo() bool
GetPrintCallerInfo returns whether the automatic addition of the calling function (with package) to the log messages is enabled.
func GetPrintSourceInfo ¶
func GetPrintSourceInfo() int8
GetPrintSourceInfo returns whether the automatic addition of the source and line number info to the log messages is enabled, and whether the file name will be printed in short or long form.
func GetTimeFormat ¶
func GetTimeFormat() string
GetTimeFormat returns the current format of log messages time.
func Infof ¶
Infof writes an informational message to the current output stream, appending a new line.
func Infoln ¶
Infoln writes an informational message to the current output stream, appending a new line.
func IsDebug ¶
func IsDebug() bool
IsDebug returns whether the debug (DebugLevel) log elevel is enabled.
func IsError ¶
func IsError() bool
IsError returns whether the error (ErrorLevel) log elevel is enabled.
func IsFatal ¶
func IsFatal() bool
IsFatal returns whether the fatal (FatalLevel) log elevel is enabled.
func IsInfo ¶
func IsInfo() bool
IsInfo returns whether the informational (InfoLevel) log elevel is enabled.
func IsPanic ¶
func IsPanic() bool
IsPanic returns whether the panic (PanicLevel) log elevel is enabled.
func IsTrace ¶
func IsTrace() bool
IsTrace returns whether the trace (TraceLevel) log elevel is enabled.
func IsWarning ¶
func IsWarning() bool
IsWarning returns whether the warning (WarnLevel) log elevel is enabled.
func Panicf ¶
Panicf writes an error message to the current output stream, appending a new line; then it panics.
func Panicln ¶
Panicln writes an error message to the current output stream, appending a new line; then it panics.
func Printf ¶
Printf is a raw version of the debug functions; it tries to interpret the message by checking if it starts with anything like "[D]" or "[W]"; if so, it delegates to the corresponding logging function, otherwise it just prints to the log stream as is, with no additional formatting.
func Println ¶
Println is a raw version of the debug functions; it tries to interpret the message by checking if it starts with anthing like "[D]" or "[W]"; if so, it delegates to the corresponding logging function, otherwise it just prints to the log stream as is, with no additional formatting.
func SetPrintCallerInfo ¶
func SetPrintCallerInfo(enabled bool)
SetPrintCallerInfo enables or disables the automatic addition of the calling function (with package) to the log messages. NOTE: enabling this feature can have severe impacts on performances since it uses reflection at runtime.
func SetPrintSourceInfo ¶
func SetPrintSourceInfo(value int8)
SetPrintSourceInfo enables or disables the automatic addition of the source and line number info to the log messages; use one among SourceFileNone, SourceFileShort and SourceFileLong here. NOTE: enabling this feature can have severe impacts on performances since it uses reflection at runtime.
func SetStream ¶
SetStream sets the stream to write messages to; if the colorise flag is set, the logger will wrap the stream so it always produces properly coloured output messages; this might be less appropriate when writing to a file.
func SetTimeFormat ¶
func SetTimeFormat(format string)
SetTimeFormat sets the format for log messages time.
func ToJSON ¶
func ToJSON(object interface{}) string
ToJSON converts an object into pretty-printed JSON format.
Types ¶
type Flag ¶
type Flag int8
Flag is used to influence some aspects of the logger's behaviour such as automatically including runtime information (source file, caller function).
type LogLevel ¶
type LogLevel int
LogLevel represents the log level.
const ( //TraceLevel is the LogLevel for trace messages TraceLevel LogLevel = iota // DebugLevel is the LogLevel for debug messages. DebugLevel // InfoLevel is the LogLevel for informational messages. InfoLevel // WarnLevel is the LogLevel for warning messages. WarnLevel // ErrorLevel is the LogLevel for error messages. ErrorLevel // FatalLevel is the LogLevel for fatal error messages. FatalLevel // PanicLevel is the LogLevel for fatal error messages that cause a panic. PanicLevel // NoneLevel is the LogLevel corresponding to no log output. NoneLevel )
func LevelFromString ¶
LevelFromString returns a log Level value by parsing the user-provided string in a lenient way; if the parsing fails, returns and error.