Documentation ¶
Overview ¶
Package log contains the Logger interface and everything related.
Index ¶
- Constants
- type Fields
- type Logger
- type LoggerAdapter
- func (l *LoggerAdapter) Debug(msg string, fields ...map[string]interface{})
- func (l *LoggerAdapter) Error(msg string, fields ...map[string]interface{})
- func (l *LoggerAdapter) Info(msg string, fields ...map[string]interface{})
- func (l *LoggerAdapter) Trace(msg string, fields ...map[string]interface{})
- func (l *LoggerAdapter) Warn(msg string, fields ...map[string]interface{})
- func (l *LoggerAdapter) WithFields(fields map[string]interface{}) Logger
- type LoggerNoop
- func (LoggerNoop) Debug(msg string, fields ...map[string]interface{})
- func (LoggerNoop) Error(msg string, fields ...map[string]interface{})
- func (LoggerNoop) Info(msg string, fields ...map[string]interface{})
- func (LoggerNoop) Trace(msg string, fields ...map[string]interface{})
- func (LoggerNoop) Warn(msg string, fields ...map[string]interface{})
- func (l LoggerNoop) WithFields(fields map[string]interface{}) Logger
Constants ¶
const ( FieldApp = "app" // Name of the application. FieldVersion = "version" // Version of the application. FieldCommit = "commit" // Commit hash. FieldBuildDate = "build_date" // Build date. FieldBuiltBy = "built_by" // Identity of build owner. FieldService = "service" // Name of the service. FieldListen = "addr" // Listened address and port. FieldServer = "server" // Name of the server. FieldError = "error" // Error causing the event. FieldSession = "session" // Current session. FieldCommand = "command" // Current command being processed. FieldResponse = "response" // Current response (to be) emitted. )
Name of fields, exhaustive list.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fields ¶
type Fields map[string]interface{}
Fields is used to define the content of an event with structured fields. It can be used as a shorthand for map[string]interface{}.
type Logger ¶
type Logger interface { Trace(msg string, fields ...map[string]interface{}) Debug(msg string, fields ...map[string]interface{}) Info(msg string, fields ...map[string]interface{}) Warn(msg string, fields ...map[string]interface{}) Error(msg string, fields ...map[string]interface{}) // WithFields annotates a logger with some context and return it as a new instance. WithFields(fields map[string]interface{}) Logger }
Logger is the fundamental interface for all log operations.
var DefaultLogger Logger = LoggerNoop{}
DefaultLogger is the logger user by this package.
func NewLoggerAdapter ¶
NewLoggerAdapter returns a new Logger instance.
type LoggerAdapter ¶
type LoggerAdapter struct {
// contains filtered or unexported fields
}
LoggerAdapter is a Logger implementation that wrap a Logur logger.
func (*LoggerAdapter) Debug ¶
func (l *LoggerAdapter) Debug(msg string, fields ...map[string]interface{})
Debug logs a debug event.
func (*LoggerAdapter) Error ¶
func (l *LoggerAdapter) Error(msg string, fields ...map[string]interface{})
Error logs an error event.
func (*LoggerAdapter) Info ¶
func (l *LoggerAdapter) Info(msg string, fields ...map[string]interface{})
Info logs an info event.
func (*LoggerAdapter) Trace ¶
func (l *LoggerAdapter) Trace(msg string, fields ...map[string]interface{})
Trace logs a trace event.
func (*LoggerAdapter) Warn ¶
func (l *LoggerAdapter) Warn(msg string, fields ...map[string]interface{})
Warn logs a warning event.
func (*LoggerAdapter) WithFields ¶
func (l *LoggerAdapter) WithFields(fields map[string]interface{}) Logger
WithFields annotates a logger with some context and it as a new instance.
type LoggerNoop ¶
type LoggerNoop struct{}
LoggerNoop is a Logger implementation that does nothing.
func (LoggerNoop) Debug ¶
func (LoggerNoop) Debug(msg string, fields ...map[string]interface{})
Debug for LoggerNoop does nothing.
func (LoggerNoop) Error ¶
func (LoggerNoop) Error(msg string, fields ...map[string]interface{})
Error for LoggerNoop does nothing.
func (LoggerNoop) Info ¶
func (LoggerNoop) Info(msg string, fields ...map[string]interface{})
Info for LoggerNoop does nothing.
func (LoggerNoop) Trace ¶
func (LoggerNoop) Trace(msg string, fields ...map[string]interface{})
Trace for LoggerNoop does nothing.
func (LoggerNoop) Warn ¶
func (LoggerNoop) Warn(msg string, fields ...map[string]interface{})
Warn for LoggerNoop does nothing.
func (LoggerNoop) WithFields ¶
func (l LoggerNoop) WithFields(fields map[string]interface{}) Logger
WithFields for LoggerNoop does nothing.