Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MessageArgs ¶
MessageArgs is a helper function for convenience.
Types ¶
type DefaultLogger ¶ added in v1.0.2
type DefaultLogger struct {
// contains filtered or unexported fields
}
DefaultLogger is the concrete implementation of the Logger interface, wrapping zap.SugaredLogger. This structure is exported to satisfy GoDoc requirements, but NewLogger returns the Logger interface.
func (*DefaultLogger) Close ¶ added in v1.0.2
func (l *DefaultLogger) Close()
Close flushes any buffered log entries. Mandatory to call with defer.
func (*DefaultLogger) Debug ¶ added in v1.0.2
func (l *DefaultLogger) Debug(msg Message, data Json)
Debug logs a message at Debug level.
func (*DefaultLogger) Error ¶ added in v1.0.2
func (l *DefaultLogger) Error(msg Message, data Json)
Error logs a message at Error level.
func (*DefaultLogger) Info ¶ added in v1.0.2
func (l *DefaultLogger) Info(msg Message, data Json)
Info logs a message at Info level.
func (*DefaultLogger) Warn ¶ added in v1.0.2
func (l *DefaultLogger) Warn(msg Message, data Json)
Warn logs a message at Warn level.
func (*DefaultLogger) With ¶ added in v1.0.2
func (l *DefaultLogger) With(fields Json) Logger
With returns a new Logger with the provided fields permanently attached to all subsequent log calls.
type Logger ¶
type Logger interface {
Info(Message, Json)
Error(Message, Json)
Warn(Message, Json)
Debug(Message, Json)
// Close flushes any buffered log entries. Mandatory to call with defer.
Close()
// With returns a new Logger with fields permanently attached.
With(fields Json) Logger
}
Logger interface defines the public methods for logging. It is the primary type applications interact with.
func NewLogger ¶
NewLogger initializes and returns a new Logger instance, set to the given minimum log level.
It sets up a JSON encoder suitable for production use (log aggregation systems). You must call Close() via defer immediately after initialization.
Example:
log := NewLogger(level.Info) defer log.Close()