@@ -33,7 +33,7 @@ type emitArgs struct {
3333
3434type enabledArgs struct {
3535 Ctx context.Context
36- Param api .EnabledParameters
36+ Param log .EnabledParameters
3737}
3838
3939type processor struct {
@@ -45,12 +45,18 @@ type processor struct {
4545 ShutdownCalls []context.Context
4646}
4747
48+ // Compile time assertion that processor implements log.Processor and log.FilterProcessor.
49+ var (
50+ _ log.Processor = (* processor )(nil )
51+ _ log.FilterProcessor = (* processor )(nil )
52+ )
53+
4854func (p * processor ) OnEmit (ctx context.Context , r * log.Record ) error {
4955 p .OnEmitCalls = append (p .OnEmitCalls , emitArgs {ctx , r })
5056 return p .ReturnErr
5157}
5258
53- func (p * processor ) Enabled (ctx context.Context , param api .EnabledParameters ) bool {
59+ func (p * processor ) Enabled (ctx context.Context , param log .EnabledParameters ) bool {
5460 p .EnabledCalls = append (p .EnabledCalls , enabledArgs {ctx , param })
5561 return true
5662}
@@ -78,19 +84,19 @@ func TestLogProcessorDynamicSeverity(t *testing.T) {
7884 p := NewLogProcessor (wrapped , sev )
7985
8086 ctx := context .Background ()
81- params := & api .EnabledParameters {Severity : api .SeverityDebug }
82- assert .False (t , p .Enabled (ctx , * params ), api .SeverityDebug .String ())
87+ params := log .EnabledParameters {Severity : api .SeverityDebug }
88+ assert .False (t , p .Enabled (ctx , params ), api .SeverityDebug .String ())
8389
8490 params .Severity = api .SeverityInfo
85- assert .True (t , p .Enabled (ctx , * params ), api .SeverityInfo .String ())
91+ assert .True (t , p .Enabled (ctx , params ), api .SeverityInfo .String ())
8692
8793 sev .Set (SeverityError )
8894
8995 params .Severity = api .SeverityInfo
90- assert .False (t , p .Enabled (ctx , * params ), api .SeverityInfo .String ())
96+ assert .False (t , p .Enabled (ctx , params ), api .SeverityInfo .String ())
9197
9298 params .Severity = api .SeverityError
93- assert .True (t , p .Enabled (ctx , * params ), api .SeverityError .String ())
99+ assert .True (t , p .Enabled (ctx , params ), api .SeverityError .String ())
94100}
95101
96102func TestLogProcessorOnEmit (t * testing.T ) {
@@ -135,7 +141,7 @@ func TestLogProcessorEnabled(t *testing.T) {
135141
136142 p := NewLogProcessor (wrapped , SeverityTrace1 )
137143 ctx := context .Background ()
138- param := api .EnabledParameters {}
144+ param := log .EnabledParameters {}
139145 for _ , sev := range severities {
140146 param .Severity = sev
141147 assert .True (t , p .Enabled (ctx , param ), sev .String ())
@@ -153,7 +159,7 @@ func TestLogProcessorEnabled(t *testing.T) {
153159
154160 p := NewLogProcessor (wrapped , apiSev (api .SeverityFatal4 + 1 ))
155161 ctx := context .Background ()
156- param := api .EnabledParameters {}
162+ param := log .EnabledParameters {}
157163 for _ , sev := range severities {
158164 param .Severity = sev
159165 assert .False (t , p .Enabled (ctx , param ), sev .String ())
@@ -170,16 +176,16 @@ func TestLogProcessorEnabled(t *testing.T) {
170176 pruned := struct { log.Processor }{wrapped } // Remove the Enabled method.
171177 p := NewLogProcessor (pruned , SeverityInfo )
172178 ctx := context .Background ()
173- params := & api .EnabledParameters {}
179+ params := log .EnabledParameters {}
174180
175181 params .Severity = api .SeverityDebug
176- assert .False (t , p .Enabled (ctx , * params ))
182+ assert .False (t , p .Enabled (ctx , params ))
177183
178184 params .Severity = api .SeverityInfo
179- assert .True (t , p .Enabled (ctx , * params ))
185+ assert .True (t , p .Enabled (ctx , params ))
180186
181187 params .Severity = api .SeverityError
182- assert .True (t , p .Enabled (ctx , * params ))
188+ assert .True (t , p .Enabled (ctx , params ))
183189
184190 assert .Empty (t , wrapped .EnabledCalls )
185191 })
@@ -213,7 +219,7 @@ func TestLogProcessorNilDownstream(t *testing.T) {
213219 ctx := context .Background ()
214220 r := new (log.Record )
215221 r .SetSeverity (api .SeverityTrace1 )
216- param := api .EnabledParameters {Severity : api .SeverityTrace1 }
222+ param := log .EnabledParameters {Severity : api .SeverityTrace1 }
217223 assert .NotPanics (t , func () {
218224 assert .NoError (t , p .OnEmit (ctx , r ))
219225 assert .False (t , p .Enabled (ctx , param ))
@@ -225,12 +231,12 @@ func TestLogProcessorNilDownstream(t *testing.T) {
225231func BenchmarkLogProcessor (b * testing.B ) {
226232 r := new (log.Record )
227233 r .SetSeverity (api .SeverityTrace )
228- param := api .EnabledParameters {Severity : api .SeverityTrace }
234+ param := log .EnabledParameters {Severity : api .SeverityTrace }
229235 ctx := context .Background ()
230236
231237 type combo interface {
232238 log.Processor
233- filterProcessor
239+ log. FilterProcessor
234240 }
235241
236242 run := func (p combo ) func (b * testing.B ) {
0 commit comments