示例#1
0
func Example() {
	defer sawmill.Stop()

	data := &mystruct{
		Foo:  "FOO",
		Bar:  "BAR var",
		Baz:  []byte("abc\000def"),
		List: []int{4, 5, 6},
	}

	sawmill.Info("An event occurred", data)
	sawmill.Fatal("Whoops!", sawmill.Fields{"fu": "bar"})
}
示例#2
0
func Example() {
	defer sawmill.Stop()

	logger := sawmill.DefaultLogger()

	handler, err := splunk.New(splunkURL)
	if err != nil {
		logger.Fatal("Unable to initialize splunk", sawmill.Fields{"error": err})
	}

	logger.AddHandler("splunk", handler)

	logger.Info("Splunk enabled")
}
示例#3
0
func Panicln(v ...interface{}) {
	message := fmt.Sprintln(v...)
	sm.Sync(sm.Event(sm.CriticalLevel, Prefix()+message))
	sm.Stop()
	panic(message)
}
示例#4
0
func Panicf(format string, v ...interface{}) {
	message := fmt.Sprintf(format, v...)
	sm.Sync(sm.Event(sm.CriticalLevel, Prefix()+message))
	sm.Stop()
	panic(message)
}
示例#5
0
func Fatalln(v ...interface{}) {
	sm.Sync(sm.Event(sm.CriticalLevel, Prefix()+fmt.Sprintln(v...)))
	sm.Stop()
	os.Exit(1)
}
示例#6
0
func Fatalf(format string, v ...interface{}) {
	sm.Sync(sm.Event(sm.CriticalLevel, Prefix()+fmt.Sprintf(format, v...)))
	sm.Stop()
	os.Exit(1)
}