Documentation
¶
Index ¶
- Constants
- func Debug(v ...interface{})
- func Debugf(format string, v ...interface{})
- func Error(v ...interface{})
- func Errorf(format string, v ...interface{})
- func Fatal(v ...interface{})
- func Fatalf(format string, v ...interface{})
- func Info(v ...interface{})
- func Infof(format string, v ...interface{})
- func LevelFromString(name string) int
- func SetFlags(flags int)
- func SetLevel(level int)
- func SetOutput(w io.Writer)
- func SetPrefix(prefix string)
- func Warning(v ...interface{})
- func Warningf(format string, v ...interface{})
- type Logger
- func (l *Logger) Debug(v ...interface{})
- func (l *Logger) Debugf(format string, v ...interface{})
- func (l *Logger) Error(v ...interface{})
- func (l *Logger) Errorf(format string, v ...interface{})
- func (l *Logger) Fatal(v ...interface{})
- func (l *Logger) Fatalf(format string, v ...interface{})
- func (l *Logger) Info(v ...interface{})
- func (l *Logger) Infof(format string, v ...interface{})
- func (l *Logger) Output(calldepth int, s string, level int) error
- func (l *Logger) SetFlags(flags int)
- func (l *Logger) SetLevel(level int)
- func (l *Logger) SetOutput(w io.Writer)
- func (l *Logger) SetPrefix(prefix string)
- func (l *Logger) Warning(v ...interface{})
- func (l *Logger) Warningf(format string, v ...interface{})
Constants ¶
const ( INVALID = -1 // not a valid logging level, returned by LevelFromString DEBUG = iota // messages printed with this level have a "DEBUG:" prefix INFO // messages printed with this level have a "INFO:" prefix WARNING // messages printed with this level have a "WARNING:" prefix ERROR // messages printed with this level have a "ERROR:" prefix FATAL // messages printed with this level have a "FATAL:" prefix, calls os.Exit(1) NOTSET // prints nothing from the logger )
These constants define the level of logging
const ( Ldate = 1 << iota // the date in the local time zone: 2009/01/23 Ltime // the time in the local time zone: 01:23:23 Lmicroseconds // microsecond resolution: 01:23:23.123123. assumes Ltime. Llongfile // full file name and line number: /a/b/c/d.go:23 Lshortfile // final file name element and line number: d.go:23. overrides Llongfile LUTC // if Ldate or Ltime is set, use UTC rather than the local time zone Ltruncate // truncate up to logger.maxmsglength Llevel // write logging level LstdFlags = Ldate | Ltime // initial values for the standard logger )
These flags define which text to prefix to each log entry generated by the Logger. Bits are or'ed together to control what's printed. There is no control over the order they appear (the order listed here) or the format they present (as described in the comments). The prefix is followed by a colon only when Llongfile or Lshortfile is specified. For example, flags Ldate | Ltime (or LstdFlags) produce,
2009/01/23 01:23:23 message
while flags Ldate | Ltime | Lmicroseconds | Llongfile produce,
2009/01/23 01:23:23.123123 /a/b/c/d.go:23: message
Variables ¶
This section is empty.
Functions ¶
func LevelFromString ¶
LevelFromString returns the level value for the given level name
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger redefine log.Logger and adds leveling
func New ¶
New creates a new Logger. The out variable sets the destination to which log data will be written. The prefix appears at the beginning of each generated log line. The flag argument defines the logging properties. The level argument defines the logger level of logging
func (*Logger) Debug ¶
func (l *Logger) Debug(v ...interface{})
Debug calls logger.Output to print to the logger if logging level is inferior or equal to INFO. Arguments are handled in the manner of fmt.Print with DEBUG: as message prefix
func (*Logger) Debugf ¶
Debugf calls logger.Output to print to the logger if logging level is inferior or equal to DEBUG. Arguments are handled in the manner of fmt.Printf with DEBUG: as message prefix
func (*Logger) Error ¶
func (l *Logger) Error(v ...interface{})
Error calls logger.Output to print to the logger if logging level is inferior or equal to ERROR. Arguments are handled in the manner of fmt.Print with ERROR: as message prefix
func (*Logger) Errorf ¶
Errorf calls logger.Output to print to the logger if logging level is inferior or equal to ERROR. Arguments are handled in the manner of fmt.Printf with ERROR: as message prefix
func (*Logger) Fatal ¶
func (l *Logger) Fatal(v ...interface{})
Fatal calls logger.Output to print to the logger if logging level is inferior or equal to FATAL. Arguments are handled in the manner of fmt.Print with FATAL: as message prefix
func (*Logger) Fatalf ¶
Fatalf calls logger.Output to print to the logger if logging level is inferior or equal to FATAL. Arguments are handled in the manner of fmt.Printf with FATAL: as message prefix and followed by a call to os.Exit(1)
func (*Logger) Info ¶
func (l *Logger) Info(v ...interface{})
Info calls logger.Output to print to the logger if logging level is inferior or equal to INFO. Arguments are handled in the manner of fmt.Print with INFO: as message prefix
func (*Logger) Infof ¶
Infof calls logger.Output to print to the logger if logging level is inferior or equal to INFO. Arguments are handled in the manner of fmt.Printf with INFO: as message prefix
func (*Logger) Output ¶
Output writes the output for a logging event. The string s contains the text to print after the prefix specified by the flags of the Logger. A newline is appended if the last character of s is not already a newline. Calldepth is used to recover the PC and is provided for generality, although at the moment on all pre-defined paths it will be 2.