Skip to content

Commit

Permalink
Split EnabledParameters into RW and RO types
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias committed Sep 13, 2024
1 parent 80e18a5 commit 8e3b010
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions log/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,22 @@ func WithSchemaURL(schemaURL string) LoggerOption {
})
}

// EnabledParametersBuilder is used to construct [EnabledParameters].
type EnabledParametersBuilder struct {
EnabledParameters
}

// Build returns the immutable [EnabledParameters].
func (e *EnabledParametersBuilder) Build() EnabledParameters {
return e.EnabledParameters
}

// SetSeverity sets the [Severity] level.
func (e *EnabledParametersBuilder) SetSeverity(level Severity) {
e.severity = level
e.severitySet = true
}

// EnabledParameters represents payload for [Logger]'s Enabled method.
type EnabledParameters struct {
severity Severity
Expand All @@ -138,12 +154,6 @@ type EnabledParameters struct {

// 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) {
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
}

0 comments on commit 8e3b010

Please sign in to comment.