...

Source file src/github.com/sirupsen/logrus/example_function_test.go

Documentation: github.com/sirupsen/logrus

     1  package logrus_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	log "github.com/sirupsen/logrus"
     7  	"github.com/stretchr/testify/assert"
     8  )
     9  
    10  func TestLogger_LogFn(t *testing.T) {
    11  	log.SetFormatter(&log.JSONFormatter{})
    12  	log.SetLevel(log.WarnLevel)
    13  
    14  	notCalled := 0
    15  	log.InfoFn(func() []interface{} {
    16  		notCalled++
    17  		return []interface{}{
    18  			"Hello",
    19  		}
    20  	})
    21  	assert.Equal(t, 0, notCalled)
    22  
    23  	called := 0
    24  	log.ErrorFn(func() []interface{} {
    25  		called++
    26  		return []interface{}{
    27  			"Oopsi",
    28  		}
    29  	})
    30  	assert.Equal(t, 1, called)
    31  }
    32  

View as plain text