Documentation
¶
Overview ¶
Package logger provides a simple logger interface for logging messages. It also provides an out of the box support with the Otel span. The logger is passing metadata to the span, so the logs can be easily correlated with the traces. Furthermore, the logger is recording the span as errored for error logs with a given error.
Index ¶
- func Debug(ctx context.Context, message string, args ...interface{})
- func Error(ctx context.Context, message string, err error, args ...interface{})
- func Info(ctx context.Context, message string, args ...interface{})
- func InitLogger()
- func Warn(ctx context.Context, message string, args ...interface{})
- type Attribute
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Debug ¶
Debug logs a message at the debug level.
Any attributes passed as arguments are added to the log message in the group "metadata", and in the span that is retrieved from the given context.
func Error ¶
Error logs a message at the error level.
Any attributes passed as arguments are added to the log message in the group "metadata", and in the span that is retrieved from the given context. Furthermore, if an error is passed as an argument, it is added to the log message in the attribute "error", and also sets the span as errored (if the a span cna be retrieved from the given context).
func Info ¶
Info logs a message at the info level.
Any attributes passed as arguments are added to the log message in the group "metadata", and in the span that is retrieved from the given context.
func InitLogger ¶
func InitLogger()
InitLogger initializes the logger with the given configuration.
The logger is then selected as the default logger for the application.
Types ¶
type Attribute ¶
type Attribute struct {
// contains filtered or unexported fields
}
Attribute is a wrapper around the log attributes
func (*Attribute) WithMetadata ¶
WithMetadata sets the metadata in the attribute
func (*Attribute) WithOutInjectingAttrsToSpan ¶
WithOutInjectingAttrsToSpan disables injecting attributes to the span