Categorygithub.com/ptone/stackrus
modulepackage
0.0.0-20191003224057-ea56a1ac3596
Repository: https://github.com/ptone/stackrus.git
Documentation: pkg.go.dev

# README

stackrus

Stackdriver logging plugin for logrus

See the example for usage

Note - to fully flush the hook's buffer, you need to be sure Close is called on the hook before exiting.

Logrus data field values are all converted to string label values in Stackdriver log entries per the Stackdriver API.

Levels are mapped between Logrus levels and Stackdriver severity:

{logrus.DebugLevel, logging.Debug},
{logrus.InfoLevel, logging.Info},
{logrus.WarnLevel, logging.Warning},
{logrus.ErrorLevel, logging.Error},
{logrus.FatalLevel, logging.Critical},
{logrus.PanicLevel, logging.Emergency},

You can set the logs as being related to a cloud resource by setting special logrus fields of resource.type and resource.labels.*

The resource type must match a valid stackdriver monitored resource. eg: cloud_run_revision.

This hook specifically uses "cloud.google.com/go/logging" while many other related projects are only using the deprecated "google.golang.org/api/logging/v2".

Not an official Google product.

# Packages

Copyright 2019 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.

# Functions

NewHook create a new Hook with project and logname configuration.

# Structs

Hook provides a Logrus logging hook that sends logs to Stackdriver Logging.