File: formatter_test.go

package info (click to toggle)
golang-github-juju-loggo 2.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 256 kB
  • sloc: makefile: 10
file content (32 lines) | stat: -rw-r--r-- 772 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2014 Canonical Ltd.
// Licensed under the LGPLv3, see LICENCE file for details.

package loggo_test

import (
	"time"

	gc "gopkg.in/check.v1"

	"github.com/juju/loggo/v2"
)

type formatterSuite struct{}

var _ = gc.Suite(&formatterSuite{})

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!")
}