gcloudlogging

package
v0.0.0-...-f2973a8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2024 License: MIT Imports: 6 Imported by: 3

Documentation

Overview

Package gcloudlogging provides special encoding, configuration for the encoder, and other constructs for go.uber.org/zap that make Cloud Logging understand its logs.

All Storj-run applications will most certainly use the Cloud Logging agent instead of directly feeding Cloud Logging with LogEntries. This means we need to comply with the specification to make the message, level, time, and other fields gain special meaning that later allows us to construct powerful queries. Reference: https://cloud.google.com/logging/docs/structured-logging.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogHTTPRequest

func LogHTTPRequest(req *HTTPRequest) zapcore.Field

LogHTTPRequest returns a zapcore.Field for HTTPRequest.

func LogOperation

func LogOperation(op *Operation) zapcore.Field

LogOperation returns a zapcore.field for Operation.

func NewEncoder

func NewEncoder(cfg zapcore.EncoderConfig) zapcore.Encoder

NewEncoder is like zapcore.NewJSONEncoder, but it moves fields and several keys in the log line so that Cloud Logging understands them better.

func NewEncoderConfig

func NewEncoderConfig() zapcore.EncoderConfig

NewEncoderConfig creates zapcore.EncoderConfig suited for Cloud Logging.

Types

type HTTPRequest

type HTTPRequest struct {
	RequestMethod                  string
	RequestURL                     string
	RequestSize                    int64
	Status                         int
	ResponseSize                   int64
	UserAgent                      string
	RemoteIP                       string
	ServerIP                       string
	Referer                        string
	Latency                        time.Duration
	CacheLookup                    bool
	CacheHit                       bool
	CacheValidatedWithOriginServer bool
	CacheFillBytes                 int64
	Protocol                       string
}

HTTPRequest represents HttpRequest field. See: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#httprequest

func (*HTTPRequest) MarshalLogObject

func (req *HTTPRequest) MarshalLogObject(enc zapcore.ObjectEncoder) error

MarshalLogObject implements zapcore.ObjectMarshaler. All fields are optional.

type Operation

type Operation struct {
	ID       string
	Producer string
	First    bool
	Last     bool
}

Operation represents LogEntryOperation field. See: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#LogEntryOperation

func (*Operation) MarshalLogObject

func (op *Operation) MarshalLogObject(enc zapcore.ObjectEncoder) error

MarshalLogObject implements zapcore.ObjectMarshaler. All fields are optional.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL