@@ -153,12 +153,28 @@ var tests = map[string]testcase{
153
153
text : "v=11: you see me because of -vmodule output=11" ,
154
154
v : 11 ,
155
155
vmodule : "output=11" ,
156
+ expectedOutput : `I output.go:<LINE>] "v=11: you see me because of -vmodule output=11"
157
+ ` ,
156
158
},
157
159
"other vmodule" : {
158
160
text : "v=11: you still don't see me because of -vmodule output_helper=11" ,
159
161
v : 11 ,
160
162
vmodule : "output_helper=11" ,
161
163
},
164
+ "vmodule with helper" : {
165
+ text : "v=11: you see me because of -vmodule output=11" ,
166
+ withHelper : true ,
167
+ v : 11 ,
168
+ vmodule : "output=11" ,
169
+ expectedOutput : `I output.go:<LINE>] "v=11: you see me because of -vmodule output=11"
170
+ ` ,
171
+ },
172
+ "other vmodule with helper" : {
173
+ text : "v=11: you still don't see me because of -vmodule output_helper=11" ,
174
+ withHelper : true ,
175
+ v : 11 ,
176
+ vmodule : "output_helper=11" ,
177
+ },
162
178
"log with name and values" : {
163
179
withNames : []string {"me" },
164
180
text : "test" ,
@@ -410,7 +426,7 @@ func printWithLogger(logger logr.Logger, test testcase) {
410
426
}
411
427
for _ , logger := range loggers {
412
428
if test .withHelper {
413
- loggerHelper (logger , test .text , test .values ) // <LINE>
429
+ loggerHelper (logger . V ( test . v ) , test .text , test .values ) // <LINE>
414
430
} else if test .err != nil {
415
431
logger .Error (test .err , test .text , test .values ... ) // <LINE>
416
432
} else {
@@ -480,7 +496,7 @@ func printWithKlog(test testcase) {
480
496
text = strings .Join (test .withNames , "/" ) + ": " + text
481
497
}
482
498
if test .withHelper {
483
- klogHelper (text , kv )
499
+ klogHelper (klog . Level ( test . v ), text , kv )
484
500
} else if test .err != nil {
485
501
klog .ErrorS (test .err , text , kv ... )
486
502
} else {
@@ -510,7 +526,7 @@ var _, _, printWithKlogLine, _ = runtime.Caller(0) // anchor for finding the lin
510
526
func Output (t * testing.T , config OutputConfig ) {
511
527
for n , test := range tests {
512
528
t .Run (n , func (t * testing.T ) {
513
- defer klog . ClearLogger ( )
529
+ initPrintWithKlog ( t , test )
514
530
515
531
testOutput := func (t * testing.T , expectedLine int , print func (buffer * bytes.Buffer )) {
516
532
var tmpWriteBuffer bytes.Buffer
@@ -561,7 +577,7 @@ func Output(t *testing.T, config OutputConfig) {
561
577
562
578
if config .AsBackend {
563
579
testOutput (t , printWithKlogLine - 1 , func (buffer * bytes.Buffer ) {
564
- klog .SetLogger (config .NewLogger (buffer , 10 , "" ))
580
+ klog .SetLogger (config .NewLogger (buffer , 10 , test . vmodule ))
565
581
printWithKlog (test )
566
582
})
567
583
return
0 commit comments