Skip to content

Commit

Permalink
log: Change EnabledParameters to have fields instead of methods
Browse files Browse the repository at this point in the history
  • Loading branch information
pellared committed Nov 29, 2024
1 parent bab2460 commit 51dca45
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
15 changes: 1 addition & 14 deletions log/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,18 +138,5 @@ func WithSchemaURL(schemaURL string) LoggerOption {

// EnabledParameters represents payload for [Logger]'s Enabled method.
type EnabledParameters struct {
severity Severity
severitySet bool
}

// Severity returns the [Severity] level value, or [SeverityUndefined] if no value was set.
// The ok result indicates whether the value was set.
func (r *EnabledParameters) Severity() (value Severity, ok bool) {
return r.severity, r.severitySet
}

// SetSeverity sets the [Severity] level.
func (r *EnabledParameters) SetSeverity(level Severity) {
r.severity = level
r.severitySet = true
Severity Severity
}
7 changes: 3 additions & 4 deletions sdk/log/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,9 @@ func BenchmarkLoggerEnabled(b *testing.B) {
WithProcessor(newFltrProcessor("0", false)),
WithProcessor(newFltrProcessor("1", true)),
)
logger := provider.Logger("BenchmarkLoggerEnabled")
ctx, param := context.Background(), log.EnabledParameters{}
param.SetSeverity(log.SeverityDebug)

logger := provider.Logger(b.Name())
ctx := context.Background()
param := log.EnabledParameters{Severity: log.SeverityDebug}
var enabled bool

b.ReportAllocs()
Expand Down

0 comments on commit 51dca45

Please sign in to comment.