Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Headers ¶ added in v0.0.3
Headers represents key-value pairs in the HTTP headers.
func (Headers) Get ¶ added in v0.0.3
Get gets the first value associated with the given key. If there are no values associated with the key, Get returns "".
func (Headers) MarshalLogObject ¶ added in v0.0.3
func (h Headers) MarshalLogObject(enc zapcore.ObjectEncoder) error
MarshalLogObject adds the headers in the log.
type LoggerHandler ¶
LoggerHandler creates a logger handler
func (*LoggerHandler) ServeHTTP ¶
func (l *LoggerHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements the http.Handler and call to the handler to log with a custom http.ResponseWriter that records the response code and the number of bytes sent.
type RawResponseLogger ¶
type RawResponseLogger interface {
ResponseLogger
Response() []byte
}
ResponseLogger defines an interface that a responseWrite can implement to support the capture of the status code, the number of bytes written and extra log entry fields.
func NewRawResponseLogger ¶
func NewRawResponseLogger(w http.ResponseWriter) RawResponseLogger
NewRawResponseLogger wraps the given response writer with the methods to capture the status code, the bytes written, and methods to add new log entries. It won't wrap the response writer if it's already a RawResponseLogger.
type Request ¶ added in v0.0.3
Request represents an HTTP request, it implements a zapcore.ObjectMarshaller on it.
func NewRequest ¶ added in v0.0.3
NewRequest creates a Request object from an http.Request.
func (*Request) MarshalLogObject ¶ added in v0.0.3
func (r *Request) MarshalLogObject(enc zapcore.ObjectEncoder) error
MarshalLogObject adds the properties of the request in the log.
type Response ¶ added in v0.0.3
Response represents an HTTP response, it implements a zapcore.ObjectMarshaller on it.
func (*Response) MarshalLogObject ¶ added in v0.0.3
func (r *Response) MarshalLogObject(enc zapcore.ObjectEncoder) error
MarshalLogObject adds the properties of the response in the log.
type ResponseLogger ¶
type ResponseLogger interface {
http.ResponseWriter
Size() int
StatusCode() int
Fields() map[string]interface{}
WithFields(map[string]interface{})
Field(key string) (interface{}, bool)
}
ResponseLogger defines an interface that a responseWrite can implement to support the capture of the status code, the number of bytes written and extra log entry fields.
func NewResponseLogger ¶
func NewResponseLogger(w http.ResponseWriter) ResponseLogger
NewResponseLogger wraps the given response writer with methods to capture the status code, the number of bytes written, and methods to add new log entries. It won't wrap the response writer if it's already a ResponseLogger.