Documentation ¶
Overview ¶
Example (Logger_Debug_off) ¶
newLogger(INFO).Debug("debug log message")
Output:
Example (Logger_Debug_on) ¶
newLogger(DEBUG).Debug("debug log message")
Output: DEBUG debug log message
Example (Logger_Debugf_on) ¶
newLogger(DEBUG).Debugf("%s %s %s", "debug", "log", "message")
Output: DEBUG debug log message
Example (Logger_Debugln_on) ¶
newLogger(DEBUG).Debugln("debug log message")
Output: DEBUG debug log message
Example (Logger_Error_off) ¶
newLogger(NONE).Error("error log message")
Output:
Example (Logger_Error_on) ¶
newLogger(ERROR).Error("error log message")
Output: ERROR error log message
Example (Logger_Errorf_on) ¶
newLogger(ERROR).Errorf("%s %s %s", "error", "log", "message")
Output: ERROR error log message
Example (Logger_Errorln_on) ¶
newLogger(ERROR).Errorln("error log message")
Output: ERROR error log message
Example (Logger_Fatal_off) ¶
l := newLogger(NONE) l.test = true l.Fatal("fatal log message")
Output:
Example (Logger_Fatal_on) ¶
l := newLogger(FATAL) l.test = true l.Fatal("fatal log message")
Output: FATAL fatal log message
Example (Logger_Fatalf_on) ¶
l := newLogger(FATAL) l.test = true l.Fatalf("%s %s %s", "fatal", "log", "message")
Output: FATAL fatal log message
Example (Logger_Fatalln_on) ¶
l := newLogger(FATAL) l.test = true l.Fatalln("fatal log message")
Output: FATAL fatal log message
Example (Logger_Info_off) ¶
newLogger(FATAL).Info("info log message")
Output:
Example (Logger_Info_on) ¶
newLogger(INFO).Info("info log message")
Output: INFO info log message
Example (Logger_Infof_on) ¶
newLogger(INFO).Infof("%s %s %s", "info", "log", "message")
Output: INFO info log message
Example (Logger_Infoln_on) ¶
newLogger(INFO).Infoln("info log message")
Output: INFO info log message
Example (Logger_Log) ¶
newLogger(NONE).Log("Log() log message")
Output: Log() log message
Example (Logger_Warning_off) ¶
newLogger(ERROR).Warning("warning log message")
Output:
Example (Logger_Warning_on) ¶
newLogger(WARN).Warning("warning log message")
Output: WARN warning log message
Example (Logger_Warningf_on) ¶
newLogger(WARN).Warningf("%s %s %s", "warning", "log", "message")
Output: WARN warning log message
Example (Logger_Warningln_on) ¶
newLogger(WARN).Warningln("warning log message")
Output: WARN warning log message
Index ¶
Examples ¶
- Package (Logger_Debug_off)
- Package (Logger_Debug_on)
- Package (Logger_Debugf_on)
- Package (Logger_Debugln_on)
- Package (Logger_Error_off)
- Package (Logger_Error_on)
- Package (Logger_Errorf_on)
- Package (Logger_Errorln_on)
- Package (Logger_Fatal_off)
- Package (Logger_Fatal_on)
- Package (Logger_Fatalf_on)
- Package (Logger_Fatalln_on)
- Package (Logger_Info_off)
- Package (Logger_Info_on)
- Package (Logger_Infof_on)
- Package (Logger_Infoln_on)
- Package (Logger_Log)
- Package (Logger_Warning_off)
- Package (Logger_Warning_on)
- Package (Logger_Warningf_on)
- Package (Logger_Warningln_on)
Constants ¶
const ( // NONE is the log level to indicate no log output should be generated NONE = iota // FATAL log level will only output messages at the FATAL level, this is the highest log level FATAL // ERROR log level outputs messages at the ERROR level or higher ERROR // WARN log level outputs messages at the WARN level or higher WARN // INFO log level outputs messages at the INFO level or higher INFO // DEBUG log level outputs messages at the DEBUG level or higher DEBUG )
Variables ¶
StdLogger is a shortcut to get a logger which logs to stderr with the stdlib standard logging flags (log.LstdFlags)
Functions ¶
func NewLogger ¶
NewLogger returns a new logger object which will write output to the provided io.Writer. The 'out', 'prefix' and 'flag' arguments are exactly the same as the arguments for the New() method in the golang log package. This logger inherits from the golang log.Logger, so all methods of that type are available as well, including Print* and Panic*.
The logger is initially created with the level set to INFO, but can be modified by calling ParseLevel()/SetLevel().
func ParseLevel ¶
ParseLevel accepts a string as a log level name, and returns the corresponding int value for the level
Types ¶
type AwsLogger ¶ added in v0.5.0
type AwsLogger interface {
Log(...interface{})
}
AwsLogger defines a logging implementation compatible with the AWS Go SDK Logger interface
type GoLogger ¶ added in v0.5.0
type GoLogger interface { Fatal(...interface{}) Fatalf(string, ...interface{}) Fatalln(...interface{}) Panic(...interface{}) Panicf(string, ...interface{}) Panicln(...interface{}) Print(...interface{}) Printf(string, ...interface{}) Println(...interface{}) }
GoLogger is an interface describing the methods of the golang standard library log package to write log messages
type LeveledLogger ¶ added in v0.5.0
type LeveledLogger interface { Debug(...interface{}) Debugf(string, ...interface{}) Info(...interface{}) Infof(string, ...interface{}) Warning(...interface{}) Warningf(string, ...interface{}) Error(...interface{}) Errorf(string, ...interface{}) }
LeveledLogger is an interface which describes a leveled logging implementation, which may or may not leverage the standard library log package facilities