package fog import ( "bytes" "net/http" "time" ) // Google cloud log level names, which correspond to functionality provided. GCP // has a DEFAULT log level below DEBUG, but it is not used. // // https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#logseverity const ( Debug = "DEBUG" // Debug or trace information. Info = "INFO" // Routine information, such as ongoing status or performance. Notice = "NOTICE" // Normal but significant events, such as start up, shut down, or a configuration change. Warning = "WARNING" // Warning events might cause problems. Error = "ERROR" // Error events are likely to cause problems. Critical = "CRITICAL" // Critical events cause more severe problems or outages. Alert = "ALERT" // A person must take an action immediately. Emergency = "EMERGENCY" // One or more systems are unusable. ) // Zap's log severity levels as ints, these levels get more verbose as the number gets smaller and more important // and the number gets larger (DebugLevel is -1, InfoLevel is 0, WarnLevel is 1, and so on). const ( DEBUG = -1 INFO = 0 WARN = 1 ERROR = 2 DPANIC = 3 PANIC = 4 FATAL = 5 ) // Constants for Google cloud structured logging keys // https://cloud.google.com/logging/docs/agent/logging/configuration#special-fields const ( TimeKey = "time" LevelKey = "severity" CallerKey = "caller" MessageKey = "message" StacktraceKey = "stacktrace" SourceKey = "logging.googleapis.com/sourceLocation" labelsKey = "logging.googleapis.com/labels" operationKey = "logging.googleapis.com/operation" ) const ( // errorKey is the key that error values are logged with errorKey = "error" // lvlKey is the key that numeric V level values are logged with lvlKey = "level" // gcpLabelKey is the constant that is used to check if a map is one that is passed in by the Label command gcpLabelKey = "gcpLabel." // gcpOperationKey is the constant that is used to check if a map is one that is passed in by the Operation command gcpOperationKey = "gcpOperation." ) const ( OperationKey = "logging.googleapis.com/operation" SeverityKey = "severity" ) // MiddlewareContext is a struct through which the middleware logger obtains http request information, including status // and request size, as well as response body information from the middleware handler type MiddlewareContext struct { Request *http.Request Status int Size int Body *bytes.Buffer Time time.Duration } // Option controls how the underlying Zap logger is constructed. type Option func(*options)