예제 #1
0
파일: weblogs.go 프로젝트: keep94/weblogs
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")))
}