func (w *jujudWriter) Write(entry loggo.Entry) { if strings.HasPrefix(entry.Module, "unit.") { fmt.Fprintln(w.target, w.unitFormat(entry)) } else { fmt.Fprintln(w.target, loggo.DefaultFormatter(entry)) } }
func (*formatterSuite) TestDefaultFormat(c *gc.C) { location, err := time.LoadLocation("UTC") testTime := time.Date(2013, 5, 3, 10, 53, 24, 123456, location) c.Assert(err, gc.IsNil) entry := loggo.Entry{ Level: loggo.WARNING, Module: "test.module", Filename: "some/deep/filename", Line: 42, Timestamp: testTime, Message: "hello world!", } formatted := loggo.DefaultFormatter(entry) c.Assert(formatted, gc.Equals, "2013-05-03 10:53:24 WARNING test.module filename:42 hello world!") }