Пример #1
0
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)
}
Пример #2
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())
}
Пример #3
0
func (l commonLogger) Log(w io.Writer, log *weblogs.LogRecord) {
	s := log.R.(*loggers.Snapshot)
	c := log.W.(*loggers.Capture)
	fmt.Fprintf(w, "%s - %s [%s] \"%s %s %s\" %d %d %d\n",
		loggers.StripPort(s.RemoteAddr),
		userName(log),
		log.T.Format("02/Jan/2006:15:04:05 -0700"),
		s.Method,
		s.URL.RequestURI(),
		s.Proto,
		c.Status(),
		c.Size(),
		log.Duration/time.Millisecond)
}
Пример #4
0
func (l customLogger) Log(w io.Writer, record *weblogs.LogRecord) {

	s := record.R.(*loggers.Snapshot)
	c := record.W.(*loggers.Capture)

	log.Requestf("%d %s \"%s %s %s\" %d %d%s",
		c.Status(),
		loggers.StripPort(s.RemoteAddr),
		s.Method,
		s.URL.RequestURI(),
		s.Proto,
		c.Size(),
		record.Duration/time.Millisecond,
		record.Extra)
}
Пример #5
0
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"))
}