Documentation
¶
Overview ¶
Package logger provides logging functionality.
Index ¶
- type LogLevel
- type Logger
- func (l *Logger) Close() error
- func (l *Logger) Debug(messageFormat string, messageArgs ...interface{})
- func (l *Logger) Error(messageFormat string, messageArgs ...interface{})
- func (l *Logger) Fine(messageFormat string, messageArgs ...interface{})
- func (l *Logger) Info(messageFormat string, messageArgs ...interface{})
- func (l *Logger) Log(level LogLevel, messageFormat string, messageArgs ...interface{})
- func (l *Logger) LogWithFn(level LogLevel, fn func() string)
- func (l *Logger) Trace(messageFormat string, messageArgs ...interface{})
- func (l *Logger) Warn(messageFormat string, messageArgs ...interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LogLevel ¶
type LogLevel int
LogLevel defines a set of logging levels that used to control logging output.
The logging levels are ordered. The available levels in ascending order are:
Fine Trace Debug Info Warn Error
Enabling logging at a given level also enables logging at all higher levels. For example, if desired logging level for the logger is set to Debug, the messages at Debug level, as well as Info, Warn and Error levels are all logged.
In addition there is a level Off that can be used to turn off logging.
const ( // Fine represents a level used to log the most detailed output. Fine LogLevel = 10 // Trace represents a level used to log tracing messages. Trace LogLevel = 15 // Debug represents a level used to log debug messages. Debug LogLevel = 20 // Info represents a level used to log informative messages. Info LogLevel = 30 // Warn represents a level used to log warning messages. Warn LogLevel = 40 // Error represents a level used to log error messages. Error LogLevel = 50 // Off turns off logging. Off LogLevel = 99 )
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger represents a logging object that is a wrapper for log.Logger, adding capabilities to control the desired level of messges to log and whether the log entry time is displayed in local time zone or UTC.
DefaultLogger represents a default logger that writes warning and higher priority events to stderr.
func New ¶
New creates a logger that writes messages of the specified logging level to the specified io.Writer. If useLocalTime is set to false, the log entry displays UTC time.
If specified level is set to Off or a not available value, returns nil that represents logging is disabled.
func (*Logger) Debug ¶
Debug writes the specified message at Debug level to the logger if logger's logging level is less than or equal to Debug.
The arguments for the logging message are handled in the manner of fmt.Printf.
func (*Logger) Error ¶
Error writes the specified message at Error level to the logger if logger's logging level is less than or equal to Error.
The arguments for the logging message are handled in the manner of fmt.Printf.
func (*Logger) Fine ¶
Fine writes the specified message at Fine level to the logger if logger's logging level is less than or equal to Fine.
The arguments for the logging message are handled in the manner of fmt.Printf.
func (*Logger) Info ¶
Info writes the specified message at Info level to the logger if logger's logging level is less than or equal to Info.
The arguments for the logging message are handled in the manner of fmt.Printf.
func (*Logger) Log ¶
Log writes the specified message to logger if logger's logging level is less than or equal to the specified level.
The arguments for the logging message are handled in the manner of fmt.Printf.
func (*Logger) LogWithFn ¶
LogWithFn calls the function fn if the logger's logging level is less than or equal to specified level, writes the message returned from fn to the logger.
The arguments for the logging message are handled in the manner of fmt.Printf.