zlsd

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2020 License: Apache-2.0 Imports: 4 Imported by: 5

README

zerolog-gcp

a (hopefully) straightforward LevelWriter for using zerolog with Google Cloud Logging of Google Operations, all of which used to be named Stackdriver.

Some notable features:

  • The first log written to Cloud Logging is a slow, blocking write to confirm connectivity + permissions, but all subsequent writes are non-blocking.
  • Handles converting zerolog.WarnLevel to logging.Warning.
  • Zerolog's trace level maps to Cloud Logging's Default level.
  • Cloud Logging's Alert and Emergency levels are not used.

Documentation

Index

Constants

This section is empty.

Variables

DefaultSeverityMap contains the default zerolog.Level -> logging.Severity mappings.

Functions

func NewCloudLoggingWriter

func NewCloudLoggingWriter(ctx context.Context, projectID, logID string, opts CloudLoggingOptions) (writer zerolog.LevelWriter, err error)

NewCloudLoggingWriter creates a LevelWriter that logs only to GCP Cloud Logging using non-blocking calls.

Types

type CloudLoggingOptions

type CloudLoggingOptions struct {
	// SeverityMap can be optionally specified to use instead of DefaultSeverityMap.
	SeverityMap map[zerolog.Level]logging.Severity

	// Logger can be optionally provided in lieu of constructing a logger on the caller's behalf.
	Logger *logging.Logger

	// LoggerOptions is optionally used to construct a Logger.
	LoggerOptions []logging.LoggerOption
}

CloudLoggingOptions specifies some optional configuration.

Jump to

Keyboard shortcuts

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