func (l simpleLogger) Log(w io.Writer, log *LogRecord) { s := log.R.(*loggers.Snapshot) c := log.W.(*loggers.Capture) fmt.Fprintf(w, "%s %s %s %s %d %d%s\n", log.T.Format("01/02/2006 15:04:05"), loggers.StripPort(s.RemoteAddr), s.Method, s.URL, c.Status(), log.Duration/time.Millisecond, log.Extra) }
func (l apacheCommonLogger) Log(w io.Writer, log *LogRecord) { s := log.R.(*loggers.Snapshot) c := log.W.(*loggers.Capture) fmt.Fprintf(w, "%s - %s [%s] \"%s %s %s\" %d %d\n", loggers.StripPort(s.RemoteAddr), loggers.ApacheUser(s.URL.User), log.T.Format("02/Jan/2006:15:04:05 -0700"), s.Method, s.URL.RequestURI(), s.Proto, c.Status(), c.Size()) }
func TestStripPort(t *testing.T) { verifyString(t, "[::1]", loggers.StripPort("[::1]:4050")) verifyString(t, "10.0.1.3", loggers.StripPort("10.0.1.3:25972")) verifyString(t, "10.0.1.3", loggers.StripPort("10.0.1.3")) }