github.com/franciscocpg/up@v0.1.10/internal/logs/text/text_test.go (about)

     1  package text
     2  
     3  import (
     4  	"bytes"
     5  	"io"
     6  	"os"
     7  	"testing"
     8  	"time"
     9  
    10  	"github.com/apex/log"
    11  )
    12  
    13  func init() {
    14  	log.Now = func() time.Time {
    15  		return time.Unix(0, 0)
    16  	}
    17  }
    18  
    19  func Test(t *testing.T) {
    20  	var buf bytes.Buffer
    21  
    22  	log.SetHandler(New(&buf))
    23  	log.WithField("user", "tj").WithField("id", "123").Info("hello")
    24  	log.WithField("user", "tj").Info("something broke")
    25  	log.WithField("user", "tj").Warn("something kind of broke")
    26  	log.WithField("user", "tj").Error("boom")
    27  
    28  	io.Copy(os.Stdout, &buf)
    29  }