func TestBadDial(t *testing.T) { email := New("localhost", 3041, "", "", "*****@*****.**", []string{"*****@*****.**"}) email.SetFormatFunc(testFormatFunc) log.RegisterHandler(email, log.InfoLevel) log.Info("info test") }
func TestBadEmailTemplate(t *testing.T) { badTemplate := `{{ .NonExistentField }}` // referencing non-existent field email := New("localhost", 3041, "", "", "*****@*****.**", []string{"*****@*****.**"}) email.SetEmailTemplate(badTemplate) log.RegisterHandler(email, log.InfoLevel) log.Info("info test") }
func BenchmarkLogConsoleSimpleParallel(b *testing.B) { b.ResetTimer() // log setup in TestMain b.RunParallel(func(pb *testing.PB) { for pb.Next() { log.Info("Go fast.") } }) }
func main() { cLog := console.New() log.RegisterHandler(cLog, log.AllLevels...) // Trace defer log.Trace("trace").End() log.Debug("debug") log.Info("info") log.Notice("notice") log.Warn("warn") log.Error("error") // log.Panic("panic") // this will panic log.Alert("alert") // log.Fatal("fatal") // this will call os.Exit(1) // logging with fields can be used with any of the above log.WithFields(log.F("key", "value")).Info("test info") }
func TestBadSend(t *testing.T) { email := New("localhost", 3041, "", "", "*****@*****.**", []string{"*****@*****.**"}) log.RegisterHandler(email, log.InfoLevel) server, err := net.Listen("tcp", ":3041") if err != nil { t.Errorf("Expected <nil> Got '%s'", err) } defer server.Close() go func() { for { conn, err := server.Accept() if err != nil { break } if conn == nil { continue } c := &Client{ conn: conn, address: conn.RemoteAddr().String(), time: time.Now().Unix(), bufin: bufio.NewReader(conn), bufout: bufio.NewWriter(conn), } handleClient(c, true) } }() log.Info("info") }