Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CMSHTTPRecord bool
CMSHTTPRecord
View Source
var PrintMonitRecord bool
PrintMonitRecord yields MONIT records
View Source
var UTC bool
UTC flag represents UTC time zone for log messages
Functions ¶
func LogRequest ¶
func LogRequest(w http.ResponseWriter, r *http.Request, start time.Time, cauth string, status *int, tstamp int64, bytesOut int64)
helper function to log every single user request, here we pass pointer to status code as it may change through the handler while we use defer logRequest
func LoggingMiddleware ¶
LoggingMiddleware provides logging middleware for HTTP requests https://arunvelsriram.dev/simple-golang-http-logging-middleware
Types ¶
type HTTPRecord ¶
type HTTPRecord struct { Producer string `json:"producer"` // name of the producer Type string `json:"type"` // type of metric Timestamp int64 `json:"timestamp"` // UTC milliseconds Host string `json:"host"` // used to add extra information about the node submitting your data Data LogRecord `json:"data"` // log record data }
HTTPRecord provides http record we send to logs endpoint
type LogRecord ¶
type LogRecord struct { Method string `json:"method"` // http.Request HTTP method URI string `json:"uri"` // http.RequestURI API string `json:"api"` // http service API being used System string `json:"system"` // cmsweb service name ClientIP string `json:"clientip"` // client IP address BytesSend int64 `json:"bytes_send"` // number of bytes send with HTTP request BytesReceived int64 `json:"bytes_received"` // number of bytes received with HTTP request Proto string `json:"proto"` // http.Request protocol Status int64 `json:"status"` // http.Request status code ContentLength int64 `json:"content_length"` // http.Request content-length AuthProto string `json:"auth_proto"` // authentication protocol AuthCert string `json:"auth_cert"` // auth certificate, user DN LoginName string `json:"login_name"` // login name, user DN Auth string `json:"auth"` // auth method Cipher string `json:"cipher"` // TLS cipher name Referer string `json:"referer"` // http referer UserAgent string `json:"user_agent"` // http user-agent field XForwardedHost string `json:"x_forwarded_host"` // http.Request X-Forwarded-Host XForwardedFor string `json:"x_forwarded_for"` // http.Request X-Forwarded-For RemoteAddr string `json:"remote_addr"` // http.Request remote address ResponseStatus string `json:"response_status"` // http.Response status ResponseTime float64 `json:"response_time"` // http response time RequestTime float64 `json:"request_time"` // http request time Timestamp int64 `json:"timestamp"` // record timestamp RecTimestamp int64 `json:"rec_timestamp"` // timestamp for backward compatibility with apache RecDate string `json:"rec_date"` // timestamp for backward compatibility with apache }
LogRecord represents HTTP log record
type RotateLogWriter ¶
type RotateLogWriter struct {
RotateLogs *rotatelogs.RotateLogs
}
custom rotate logger
Click to show internal directories.
Click to hide internal directories.