1
0
Fork 0
mirror of https://github.com/Luzifer/cloudkeys-go.git synced 2024-11-14 08:52:44 +00:00
cloudkeys-go/vendor/github.com/juju/loggo/writer_test.go
2017-12-28 01:56:23 +00:00

37 lines
732 B
Go

// Copyright 2014 Canonical Ltd.
// Licensed under the LGPLv3, see LICENCE file for details.
package loggo_test
import (
"bytes"
"time"
gc "gopkg.in/check.v1"
"github.com/juju/loggo"
)
type SimpleWriterSuite struct{}
var _ = gc.Suite(&SimpleWriterSuite{})
func (s *SimpleWriterSuite) TestNewSimpleWriter(c *gc.C) {
now := time.Now()
formatter := func(entry loggo.Entry) string {
return "<< " + entry.Message + " >>"
}
buf := &bytes.Buffer{}
writer := loggo.NewSimpleWriter(buf, formatter)
writer.Write(loggo.Entry{
Level: loggo.INFO,
Module: "test",
Filename: "somefile.go",
Line: 12,
Timestamp: now,
Message: "a message",
})
c.Check(buf.String(), gc.Equals, "<< a message >>\n")
}