func main() { // Load the configuration (isn't this easy?) l4g.LoadConfiguration("example.xml") // And now we're ready! l4g.Finest("This will only go to those of you really cool UDP kids! If you change enabled=true.") l4g.Debug("Oh no! %d + %d = %d!", 2, 2, 2+2) l4g.Info("About that time, eh chaps?") }
func (s *S) TestLog4goModule(c *C) { // Setup a log file log.AddFilter("file", log.DEBUG, log.NewFileLogWriter("test.log", false)) // Formatted logging can be done at any of the logging levels (Finest, Fine, Debug, Trace, Info, Warning, Error, Critical) log.Trace("Received message: %s (%d)", "Testing", 10) // Warnings, Errors, and Criticals provide an os.Error that you can use for a return //return l4g.Error("Unable to open file: %s", err) // The wrapper functions can also behave like Sprint if the first argument isn't a string portno := 1000 clientid := "123456" client := "qbui" log.Debug(portno, clientid, client) // Use a closure so that if DEBUG isn't logged, it doesn't take any time // log.Debug(func()string{ decodeRaw(raw) }) }