github.com/blend/go-sdk@v1.20220411.3/logger/stdlib_shim_test.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  package logger
     9  
    10  import (
    11  	"bytes"
    12  	"testing"
    13  
    14  	"github.com/blend/go-sdk/assert"
    15  )
    16  
    17  func TestStdlibShim(t *testing.T) {
    18  	assert := assert.New(t)
    19  
    20  	buf := new(bytes.Buffer)
    21  	log, err := New(
    22  		OptOutput(buf),
    23  		OptAll(),
    24  		OptText(OptTextHideTimestamp(), OptTextNoColor()),
    25  	)
    26  	assert.Nil(err)
    27  	defer log.Close()
    28  
    29  	shim := StdlibShim(log, OptShimWriterEventProvider(ShimWriterErrorEventProvider("error")))
    30  
    31  	shim.Println("this is a test")
    32  	shim.Println("this is another test")
    33  
    34  	assert.NotEmpty(buf.String())
    35  	assert.Equal("[error] this is a test\n[error] this is another test\n", buf.String())
    36  }