service

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Overview

Package service holds the methods necessary to support implementation of loggers that write to Google cloud service

Index

Constants

View Source
const ModeDebug = "debug"
View Source
const ModeRelease = "release"
View Source
const ModeSilent = "silent"
View Source
const ModeTesting = "testing"

Variables

View Source
var Writer = alt4Writer{}

Writer can be used to override a normal/default go logger to write it's output to Google cloud logging This writer still respects log grouping if you're grouping your request logs Example log.SetOutput(Writer) for the default log package

Functions

func CloseGroup

func CloseGroup(status int, labels map[string]string)

func InitGroup

func InitGroup(httpRequest *http.Request) time.Time

func Log

func Log(callDepth int, message string, level logging.Severity, logTime time.Time)

Log Creates a log entry and writes it to Google cloud logging in the background. This function should not be called directly and should instead be used from helper functions under the `log` package.

func LogTime

func LogTime() time.Time

func SetDebugOutput

func SetDebugOutput(w io.Writer)

SetDebugOutput Is used to specify where alt4 emits additional output e.g. when facing network errors. Defaults os.Stderr

func SetMode

func SetMode(mode string)

SetMode Sets the behaviour of alt4 based on the following: `release` - Under this mode logs are written to Google cloud and not emitted to stdout `debug` - Under this mode logs are written to Google cloud and emitted to stdout `testing` - Under this mode logs are not written to Google cloud, just emitted to stdout `silent` - Under this mode logs are not written to Google cloud or emitted to stdout Mode can also be set using environment variable ALT4_MODE Default mode is `release`

func SetMonitoredResource added in v1.0.1

func SetMonitoredResource(resourceType string, labels map[string]string)

SetMonitoredResource sets the monitored resource that is the source of log entries This accepts the type e.g. "gae_app", "cloud_run_revision" and labels which are simply a map of the resource labels The easiest way to get these values is to check a previous log entry printed by the same resource to CGP logging

Types

This section is empty.

Jump to

Keyboard shortcuts

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