Documentation
¶
Overview ¶
Package requestlog provides an http.Handler that logs information about requests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
// Request is the http request that has been completed.
//
// This request's Body is always nil, regardless of the actual request body.
Request *http.Request
ReceivedTime time.Time
RequestBodySize int64
Status int
ResponseHeaderSize int64
ResponseBodySize int64
Latency time.Duration
TraceID trace.TraceID
SpanID trace.SpanID
// Deprecated. This value is available by evaluating Request.Referer().
Referer string
// Deprecated. This value is available directing in Request.Proto.
Proto string
// Deprecated. This value is available directly in Request.Method.
RequestMethod string
// Deprecated. This value is available directly in Request.URL.
RequestURL string
// Deprecated. This value is available by evaluating Request.Header.
RequestHeaderSize int64
// Deprecated. This value is available by evaluating Request.Header.
UserAgent string
// Deprecated. This value is available by evaluating Request.RemoteAddr..
RemoteIP string
// Deprecated. This value is available by evaluating reading the
// http.LocalAddrContextKey value from the context returned by Request.Context().
ServerIP string
}
Entry records information about a completed HTTP request.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
A Handler emits request information to a Logger.
func NewHandler ¶
NewHandler returns a handler that emits information to log and calls h.ServeHTTP.
type Logger ¶
type Logger interface {
Log(*Entry)
}
Logger wraps the Log method. Log must be safe to call from multiple goroutines. Log must not hold onto an Entry after it returns.
type NCSALogger ¶
type NCSALogger struct {
// contains filtered or unexported fields
}
An NCSALogger writes log entries to an io.Writer in the Combined Log Format.
Details at http://httpd.apache.org/docs/current/logs.html#combined
func NewNCSALogger ¶
func NewNCSALogger(w io.Writer, onErr func(error)) *NCSALogger
NewNCSALogger returns a new logger that writes to w. A nil onErr is treated the same as func(error) {}.
func (*NCSALogger) Log ¶
func (l *NCSALogger) Log(ent *Entry)
Log writes an entry line to its writer. Multiple concurrent calls will produce sequential writes to its writer.
type StackdriverLogger ¶
type StackdriverLogger struct {
// contains filtered or unexported fields
}
A StackdriverLogger writes log entries in the Stackdriver forward JSON format. The record's fields are suitable for consumption by Stackdriver Logging.
func NewStackdriverLogger ¶
func NewStackdriverLogger(w io.Writer, onErr func(error)) *StackdriverLogger
NewStackdriverLogger returns a new logger that writes to w. A nil onErr is treated the same as func(error) {}.
func (*StackdriverLogger) Log ¶
func (l *StackdriverLogger) Log(ent *Entry)
Log writes a record to its writer. Multiple concurrent calls will produce sequential writes to its writer.