You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2026-06-03 18:35:08 +02:00
Add the Enabled method to the Logger (#5071)
* Add the Enabled method to the Logger * Add a changelog entry * Rename enabled.go to min_sev.go * Remove MinSeverityProcessor * Document lack of interaction between OnEmit and Enabled * Update sdk/log/processor.go --------- Co-authored-by: Robert Pająk <pellared@hotmail.com>
This commit is contained in:
@@ -29,6 +29,28 @@ type Logger interface {
|
||||
// Implementations of this method need to be safe for a user to call
|
||||
// concurrently.
|
||||
Emit(ctx context.Context, record Record)
|
||||
|
||||
// Enabled returns whether the Logger emits for the given context and
|
||||
// record.
|
||||
//
|
||||
// The passed record is likely to be a partial record with only the
|
||||
// bridge-relevant information being provided (e.g a record with only the
|
||||
// Severity set). If a Logger needs more information than is provided, it
|
||||
// is said to be in an indeterminate state (see below).
|
||||
//
|
||||
// The returned value will be true when the Logger will emit for the
|
||||
// provided context and record, and will be false if the Logger will not
|
||||
// emit. The returned value may be true or false in an indeterminate state.
|
||||
// An implementation should default to returning true for an indeterminate
|
||||
// state, but may return false if valid reasons in particular circumstances
|
||||
// exist (e.g. performance, correctness).
|
||||
//
|
||||
// The record should not be held by the implementation. A copy should be
|
||||
// made if the record needs to be held after the call returns.
|
||||
//
|
||||
// Implementations of this method need to be safe for a user to call
|
||||
// concurrently.
|
||||
Enabled(ctx context.Context, record Record) bool
|
||||
}
|
||||
|
||||
// LoggerOption applies configuration options to a [Logger].
|
||||
|
||||
@@ -45,3 +45,6 @@ type Logger struct{ embedded.Logger }
|
||||
|
||||
// Emit does nothing.
|
||||
func (Logger) Emit(context.Context, log.Record) {}
|
||||
|
||||
// Enabled returns false. No log records are ever emitted.
|
||||
func (Logger) Enabled(context.Context, log.Record) bool { return false }
|
||||
|
||||
Reference in New Issue
Block a user