Documentation
¶
Index ¶
- Constants
- type LogEmitter
- func (s *LogEmitter) Debug(ctx context.Context, msg string, attrs ...attribute.KeyValue)
- func (s *LogEmitter) EmitRaw(ctx context.Context, bytes []byte)
- func (s *LogEmitter) EmitWithContext(ctx context.Context, severity log.Severity, message string, ...)
- func (s *LogEmitter) Error(ctx context.Context, msg string, err error, attrs ...attribute.KeyValue)
- func (s *LogEmitter) Fatal(ctx context.Context, msg string, attrs ...attribute.KeyValue)
- func (s *LogEmitter) Info(ctx context.Context, msg string, attrs ...attribute.KeyValue)
- func (s *LogEmitter) Panic(ctx context.Context, msg string, attrs ...attribute.KeyValue)
- func (s *LogEmitter) Trace(ctx context.Context, msg string, attrs ...attribute.KeyValue)
- func (s *LogEmitter) Warn(ctx context.Context, msg string, attrs ...attribute.KeyValue)
Constants ¶
View Source
const AttributeLogSource = "log.source" // The source of the log (e.g., access, error).
View Source
const AttributeSpanId = "span.id" // The ID of the span associated with the log.
View Source
const AttributeTraceId = "trace.id" // The ID of the trace associated with the log.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LogEmitter ¶
type LogEmitter struct {
// contains filtered or unexported fields
}
LogEmitter wraps the OTel logger with a specific log source name (e.g., accces, error).
func NewLogEmitter ¶
func NewLogEmitter(source string) *LogEmitter
NewLogEmitter returns a logger pre-tagged with the given source.
func (*LogEmitter) EmitRaw ¶
func (s *LogEmitter) EmitRaw(ctx context.Context, bytes []byte)
EmitRaw emits a raw log message, and assumes the message is already formatted. It does not add any attributes or severity level to the log record. This is useful for logging messages that are already structured or formatted.
func (*LogEmitter) EmitWithContext ¶
func (s *LogEmitter) EmitWithContext(ctx context.Context, severity log.Severity, message string, attrs ...attribute.KeyValue)
EmitWithContext emits a log message with the given severity and attributes. It also extracts trace/span information from the context and adds it to the log record.
Click to show internal directories.
Click to hide internal directories.