Documentation ¶
Overview ¶
Package logtest is a testing helper package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type EmittedRecord ¶ added in v0.4.0
EmittedRecord holds a log record the instrumentation received, alongside its context.
func (EmittedRecord) Context ¶ added in v0.4.0
func (rwc EmittedRecord) Context() context.Context
Context provides the context emitted with the record.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option configures a Recorder.
func WithEnabledFunc ¶
WithEnabledFunc allows configuring whether the Recorder is enabled for specific log entries or not.
By default, the Recorder is enabled for every log entry.
type RecordFactory ¶
type RecordFactory struct { Timestamp time.Time ObservedTimestamp time.Time Severity log.Severity SeverityText string Body log.Value Attributes []log.KeyValue }
RecordFactory is used to facilitate unit testing bridge implementations that make use of a go.opentelemetry.io/otel/log.Record
Do not use RecordFactory to create records in production code.
func (RecordFactory) NewRecord ¶
func (b RecordFactory) NewRecord() log.Record
NewRecord returns a log record.
type Recorder ¶
type Recorder struct { embedded.LoggerProvider // contains filtered or unexported fields }
Recorder is a recorder that stores all received log records in-memory.
func NewRecorder ¶
NewRecorder returns a new Recorder.
func (*Recorder) Logger ¶
Logger returns a copy of Recorder as a log.Logger with the provided scope information.
func (*Recorder) Reset ¶
func (r *Recorder) Reset()
Reset clears the in-memory log records for all loggers.
func (*Recorder) Result ¶
func (r *Recorder) Result() []*ScopeRecords
Result returns the current in-memory recorder log records.
type ScopeRecords ¶
type ScopeRecords struct { // Name is the name of the instrumentation scope. Name string // Version is the version of the instrumentation scope. Version string // SchemaURL of the telemetry emitted by the scope. SchemaURL string // Attributes of the telemetry emitted by the scope. Attributes attribute.Set // Records are the log records, and their associated context this // instrumentation scope recorded. Records []EmittedRecord }
ScopeRecords represents the records for a single instrumentation scope.