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.