github.com/hyperledger/burrow@v0.34.5-0.20220512172541-77f09336001d/logging/logconfig/config_test.go (about)

     1  package logconfig
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/BurntSushi/toml"
     7  	"github.com/stretchr/testify/assert"
     8  	"github.com/stretchr/testify/require"
     9  )
    10  
    11  func TestLoggingConfig_String(t *testing.T) {
    12  	complexConfig := &LoggingConfig{
    13  		RootSink: Sink().
    14  			SetTransform(LabelTransform(false, "Info", "Trace")).
    15  			AddSinks(
    16  				Sink().
    17  					SetOutput(StdoutOutput()).
    18  					SetTransform(FilterTransform(ExcludeWhenAnyMatches,
    19  						"Foo", "Bars")).
    20  					AddSinks(
    21  						Sink().
    22  							SetOutput(StderrOutput()),
    23  						Sink().
    24  							SetOutput(StdoutOutput()),
    25  					),
    26  			),
    27  	}
    28  	lc := new(LoggingConfig)
    29  	_, err := toml.Decode(complexConfig.TOMLString(), lc)
    30  	require.NoError(t, err)
    31  	assert.Equal(t, complexConfig, lc)
    32  }