Пример #1
0
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())
}
Пример #2
0
func TestApacheUser(t *testing.T) {
	verifyString(t, "-", loggers.ApacheUser(nil))
	verifyString(t, "-", loggers.ApacheUser(url.User("")))
	verifyString(t, "tom", loggers.ApacheUser(url.User("tom")))
}