Exemplo n.º 1
0
func ExampleGetLogger() {
	l := log.GetLogger("my/lib")
	h := log.NewStdFormatter(log.SyncWriter(os.Stdout), "", log.Llevel|log.Lname)
	l.SetHandler(h)
	l2 := log.GetLogger("my/lib/module")

	l3 := l2.With("k", "v")

	l3.NOTICE("notice")
	// Output:
	// <5> (my/lib/module) notice k=v
}
Exemplo n.º 2
0
func ExampleApplyHandlerOptions() {
	h := log.NewMinFormatter(log.SyncWriter(os.Stdout), log.PrefixOpt("PFX:"))
	l := log.GetLogger("mylog")
	l.SetHandler(h)
	l.ERROR("fejl")
	l.ApplyHandlerOptions(log.FlagsOpt(log.Llevel | log.Lname))
	l.WARN("advarsel")
	// Output:
	// <3>PFX:fejl
	// <4>PFX: (mylog) advarsel
}
Exemplo n.º 3
0
func ExampleSetPrintLevel() {
	l := log.GetLogger("my/lib")
	h := log.NewStdFormatter(log.SyncWriter(os.Stdout), "", log.Llevel|log.Lname)
	l.SetHandler(h)
	l.AutoColoring()
	l.SetLevel(syslog.LOG_ERROR)
	l.SetPrintLevel(syslog.LOG_NOTICE, false)

	l.Print("ignoring level")
	// Output:
	// <5> (my/lib) ignoring level

}
Exemplo n.º 4
0
func ExampleWith() {
	l := log.GetLogger("my/lib")
	h := log.NewStdFormatter(log.SyncWriter(os.Stdout), "", log.Llevel|log.Lname)
	l.SetHandler(h)
	l.SetLevel(syslog.LOG_ERROR)

	l2 := l.With("key", "value")

	l3 := l2.With("more", "data")

	l3.ERROR("message")
	// Output:
	// <3> (my/lib) message more=data key=value

}