logger

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

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) Debug

func (s *LogEmitter) Debug(ctx context.Context, msg string, attrs ...attribute.KeyValue)

Debug logs a debug message.

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.

func (*LogEmitter) Error

func (s *LogEmitter) Error(ctx context.Context, msg string, err error, attrs ...attribute.KeyValue)

Error logs an error message.

func (*LogEmitter) Fatal

func (s *LogEmitter) Fatal(ctx context.Context, msg string, attrs ...attribute.KeyValue)

Fatal logs a fatal error message

func (*LogEmitter) Info

func (s *LogEmitter) Info(ctx context.Context, msg string, attrs ...attribute.KeyValue)

Info logs an informational message.

func (*LogEmitter) Panic

func (s *LogEmitter) Panic(ctx context.Context, msg string, attrs ...attribute.KeyValue)

Fatal logs a fatal error message

func (*LogEmitter) Trace

func (s *LogEmitter) Trace(ctx context.Context, msg string, attrs ...attribute.KeyValue)

Debug logs a debug message.

func (*LogEmitter) Warn

func (s *LogEmitter) Warn(ctx context.Context, msg string, attrs ...attribute.KeyValue)

Warn logs a warning message.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL