@@ -307,6 +307,7 @@ var _ = Describe("Zap log level flag options setup", func() {
307
307
info = "info text"
308
308
debug1 = "debug 1 text"
309
309
debug2 = "debug 2 text"
310
+ debug3 = "debug 3 text"
310
311
)
311
312
312
313
BeforeEach (func () {
@@ -370,8 +371,25 @@ var _ = Describe("Zap log level flag options setup", func() {
370
371
Expect (string (outRaw )).Should (ContainSubstring (debug1 ))
371
372
})
372
373
374
+ It ("Should set integer debug level 1 for zap-log-level flag." , func () {
375
+ args := []string {"--zap-log-level=1" , "--zap-devel=true" }
376
+ fromFlags .BindFlags (& fs )
377
+ err := fs .Parse (args )
378
+ Expect (err ).ToNot (HaveOccurred ())
379
+ logOut := new (bytes.Buffer )
380
+
381
+ logger := New (UseFlagOptions (& fromFlags ), WriteTo (logOut ))
382
+ logger .V (0 ).Info (info )
383
+ logger .V (1 ).Info (debug1 )
384
+
385
+ outRaw := logOut .Bytes ()
386
+
387
+ Expect (string (outRaw )).Should (ContainSubstring (info ))
388
+ Expect (string (outRaw )).Should (ContainSubstring (debug1 ))
389
+ })
390
+
373
391
It ("Should set integer debug level 2 for zap-log-level flag." , func () {
374
- args := []string {"--zap-log-level=2" }
392
+ args := []string {"--zap-log-level=2" , "--zap-devel=true" }
375
393
fromFlags .BindFlags (& fs )
376
394
err := fs .Parse (args )
377
395
Expect (err ).ToNot (HaveOccurred ())
@@ -389,6 +407,25 @@ var _ = Describe("Zap log level flag options setup", func() {
389
407
Expect (string (outRaw )).Should (ContainSubstring (debug2 ))
390
408
391
409
})
410
+ It ("Should set integer debug level 3 for zap-log-level flag." , func () {
411
+ args := []string {"--zap-log-level=3" , "--zap-devel=false" }
412
+ fromFlags .BindFlags (& fs )
413
+ err := fs .Parse (args )
414
+ Expect (err ).ToNot (HaveOccurred ())
415
+ logOut := new (bytes.Buffer )
416
+
417
+ logger := New (UseFlagOptions (& fromFlags ), WriteTo (logOut ))
418
+ logger .V (0 ).Info (info )
419
+ logger .V (1 ).Info (debug1 )
420
+ logger .V (3 ).Info (debug3 )
421
+
422
+ outRaw := logOut .Bytes ()
423
+
424
+ Expect (string (outRaw )).Should (ContainSubstring (info ))
425
+ Expect (string (outRaw )).Should (ContainSubstring (debug1 ))
426
+ Expect (string (outRaw )).Should (ContainSubstring (debug3 ))
427
+
428
+ })
392
429
393
430
})
394
431
0 commit comments