Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var EncoderConfig = zapcore.EncoderConfig{ TimeKey: "eventTime", LevelKey: "severity", NameKey: "logger", CallerKey: "caller", MessageKey: "message", StacktraceKey: "stacktrace", LineEnding: zapcore.DefaultLineEnding, EncodeLevel: encodeLevel, EncodeTime: zapcore.ISO8601TimeEncoder, EncodeDuration: zapcore.SecondsDurationEncoder, EncodeCaller: zapcore.ShortCallerEncoder, }
Functions ¶
func HTTP ¶
func HTTP(req *HTTPPayload) zap.Field
HTTP adds the correct Stackdriver "HTTP" field.
see: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#HttpRequest
func NewDevelopmentConfig ¶
func NewProductionConfig ¶
Types ¶
type HTTPPayload ¶
type HTTPPayload struct {
// The request method. Examples: "GET", "HEAD", "PUT", "POST".
RequestMethod string
// The scheme (http, https), the host name, the path and the query portion of
// the URL that was requested.
//
// Example: "http://example.com/some/info?color=red".
RequestURL string
// The size of the HTTP request message in bytes, including the request
// headers and the request body.
RequestSize int
// The response code indicating the status of response.
//
// Examples: 200, 404.
Status int
// The size of the HTTP response message sent back to the client, in bytes,
// including the response headers and the response body.
ResponseSize int
// The user agent sent by the client.
//
// Example: "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Q312461; .NET CLR 1.0.3705)".
UserAgent string
// The IP address (IPv4 or IPv6) of the client that issued the HTTP request.
//
// Examples: "192.168.1.1", "FE80::0202:B3FF:FE1E:8329".
RemoteIP string
// The IP address (IPv4 or IPv6) of the origin server that the request was
// sent to.
ServerIP string
// The referrer URL of the request, as defined in HTTP/1.1 Header Field
// Definitions.
Referer string
// Protocol used for the request.
//
// Examples: "HTTP/1.1", "HTTP/2", "websocket"
Protocol string
// The request processing latency on the server, from the time the request was
// received until the response was sent.
//
// A duration in seconds with up to nine fractional digits, terminated by 's'.
//
// Example: "3.5s".
Latency time.Duration
}
HTTPPayload is the complete payload that can be interpreted by Stackdriver as a HTTP request.
func NewHTTP ¶
func NewHTTP(req *http.Request) *HTTPPayload
NewHTTP returns a new HTTPPayload struct, based on the passed in http.Request object.
func (HTTPPayload) MarshalLogObject ¶
func (req HTTPPayload) MarshalLogObject(enc zapcore.ObjectEncoder) error
MarshalLogObject implements zapcore.ObjectMarshaller
Click to show internal directories.
Click to hide internal directories.