Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

67 lines (59 sloc) 1.547 kB
package timber
import (
"testing"
)
func TestConsole(t *testing.T) {
log := NewTimber()
console := new(ConsoleWriter)
formatter := NewPatFormatter("[%D %T] [%L] %-10x %M")
idx := log.AddLogger(ConfigLogger{LogWriter: console,
Level: DEBUG,
Formatter: formatter})
log.Error("what error? %v", idx)
log.Close()
}
func TestFile(t *testing.T) {
log := NewTimber()
writer, _ := NewFileWriter("test.log")
formatter := NewPatFormatter("[%D %T] [%L] %-10x %M")
idx := log.AddLogger(ConfigLogger{LogWriter: writer,
Level: FINEST,
Formatter: formatter})
log.Error("what error? %v", idx)
log.Warn("I'm waringing you!")
log.Info("FYI")
log.Fine("you soo fine!")
log.Close()
}
func TestXmlConfig(t *testing.T) {
log := NewTimber()
log.LoadXMLConfig("timber.xml")
log.Info("Message to XML loggers")
log.Close()
}
func TestJsonConfig(t *testing.T) {
log := NewTimber()
log.LoadJSONConfig("timber.json")
log.Info("Message to JSON loggers")
log.Close()
}
func TestDefaultLogger(t *testing.T) {
console := new(ConsoleWriter)
formatter := NewPatFormatter("%DT%T %L %-10x %M")
AddLogger(ConfigLogger{LogWriter: console,
Level: DEBUG,
Formatter: formatter})
Warn("Some sweet default logging")
Close()
}
func TestDoubleClose(t *testing.T) {
log := NewTimber()
console := new(ConsoleWriter)
formatter := NewPatFormatter("%DT%T %L %-10x %M")
log.AddLogger(ConfigLogger{LogWriter: console,
Level: DEBUG,
Formatter: formatter})
log.Close()
log.Close() // call Close twice
log.Warn("Don't panic")
}
Jump to Line
Something went wrong with that request. Please try again.