Documentation
¶
Index ¶
- type Event
- func (e *Event) HTTP(req *HTTPPayload) *zerolog.Event
- func (e *Event) Labels(labels ...*LabelSource) *zerolog.Event
- func (e *Event) Operation(id, producer string, first, last bool) *zerolog.Event
- func (e *Event) OperationContinue(id, producer string) *zerolog.Event
- func (e *Event) OperationEnd(id, producer string) *zerolog.Event
- func (e *Event) OperationStart(id, producer string) *zerolog.Event
- func (e *Event) TraceContext(trace string, spanId string, sampled bool, projectID string) *zerolog.Event
- type GAELatency
- type HTTPPayload
- type LabelSource
- type Latency
- type Logger
- func (l *Logger) Debug() *Event
- func (l *Logger) Err(err error) *Event
- func (l *Logger) Error() *Event
- func (l *Logger) Fatal() *Event
- func (l *Logger) Info() *Event
- func (l *Logger) Log() *Event
- func (l Logger) Output(w io.Writer) Logger
- func (l *Logger) Panic() *Event
- func (l *Logger) Print(v ...interface{})
- func (l *Logger) Printf(format string, v ...interface{})
- func (l *Logger) Trace() *Event
- func (l *Logger) Warn() *Event
- func (l *Logger) WithLevel(level zerolog.Level) *Event
- func (l Logger) Write(p []byte) (n int, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶ added in v0.0.2
func (*Event) HTTP ¶ added in v0.0.2
func (e *Event) HTTP(req *HTTPPayload) *zerolog.Event
HTTP adds the httpRequest field to the *zerolog.Event context
func (*Event) Labels ¶ added in v0.1.0
func (e *Event) Labels(labels ...*LabelSource) *zerolog.Event
Labels takes LabelSource structs, filters the ones that have their key start with the string `labels.` and their value type set to string type. It then wraps those key/value pairs in a top-level `labels` namespace.
func (*Event) Operation ¶ added in v0.1.0
Operation adds the correct Cloud Logging "operation" field.
Additional information about a potentially long-running operation with which a log entry is associated.
func (*Event) OperationContinue ¶ added in v0.1.0
OperationContinue is a function for logging `Operation`. It should be called for any non-start/end operation log.
func (*Event) OperationEnd ¶ added in v0.1.0
OperationEnd is a function for logging `Operation`. It should be called for the last operation log.
func (*Event) OperationStart ¶ added in v0.1.0
OperationStart is a function for logging `Operation`. It should be called for the first operation log.
func (*Event) TraceContext ¶ added in v0.1.0
func (e *Event) TraceContext(trace string, spanId string, sampled bool, projectID string) *zerolog.Event
TraceContext adds the "trace", "span", "trace_sampled" fields to the *zerolog.Event context.
see: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry
type GAELatency ¶ added in v0.0.3
GAELatency is the Latency for GAE and Cloud Run.
type HTTPPayload ¶ added in v0.0.3
type HTTPPayload struct {
RequestMethod string `json:"requestMethod"`
RequestURL string `json:"requestUrl"`
RequestSize string `json:"requestSize"`
Status int `json:"status"`
ResponseSize string `json:"responseSize"`
UserAgent string `json:"userAgent"`
RemoteIP string `json:"remoteIp"`
ServerIP string `json:"serverIp"`
Referer string `json:"referer"`
Latency Latency `json:"latency"`
CacheLookup bool `json:"cacheLookup"`
CacheHit bool `json:"cacheHit"`
CacheValidatedWithOriginServer bool `json:"cacheValidatedWithOriginServer"`
CacheFillBytes string `json:"cacheFillBytes"`
Protocol string `json:"protocol"`
}
HTTPPayload is the struct consists of http request related components. Details are in following link. https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#HttpRequest
type LabelSource ¶ added in v0.1.2
func Label ¶ added in v0.1.0
func Label(key, value string) *LabelSource
Label adds an optional label to the payload in the format of `key: value`. Key of label must start with `labels.`
type Latency ¶ added in v0.0.3
type Latency interface{}
Latency is the interface of the request processing latency on the server. The format of the Latency should differ for GKE and for GAE, Cloud Run.
type Logger ¶
func NewDevelopmentLogger ¶ added in v0.0.3
func NewDevelopmentLogger() *Logger
NewDevelopmentLogger returns a configured logger for development. It outputs debug level and above logs, and sampling is disabled.
func NewProductionLogger ¶ added in v0.0.3
func NewProductionLogger() *Logger
NewProductionLogger returns a configured logger for production. It outputs info level and above logs with sampling.