sdhook

package module
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: May 26, 2020 License: MIT Imports: 19 Imported by: 0

README

About sdhook

Package sdhook provides a logrus compatible hook for Google Stackdriver logging.

This is a hard fork of github.com/knq/sdhook. It adds semantic versioning and replaces deprecated google.golang.org/api/logging/v2 with cloud.google.com/go/logging

Installation

Install in the usual Go way:

go get -u github.com/orian/sdhook

Usage

Simply create the hook, and add it to a logrus logger:

// create hook using service account credentials
h, err := sdhook.New(
	sdhook.GoogleServiceAccountCredentialsFile("./credentials.json"),
)

// create logger with extra fields
//
// logrus fields will be converted to Stackdriver labels
logger := logrus.New().WithFields(logrus.Fields{
	"field1": 15,
	"field2": 20,
})

// add hook
logger.Hooks.Add(h)

// log something
logger.Printf("something %d", 15)

The example above sends log entries directly to the logging API. If you have the logging agent running, you can send log entries to it instead, with the added benefit of having extra instance metadata added to your log entries by the agent. In the example above, the initialization would simply be:

// create hook using the logging agent
h, err := sdhook.New(
	sdhook.GoogleLoggingAgent(),
)

Please also see example/example.go for a more complete example.

Error Reporting

If you'd like to enable sending errors to Google's Error Reporting (https://cloud.google.com/error-reporting/), you have to set the name of the service, app or system you're running. Following the example above, the initialization would then be:

// create hook using the logging agent
h, err := sdhook.New(
	sdhook.GoogleLoggingAgent(),
	sdhook.ErrorReportingService("your-great-app"),
)

The value of the ErrorReportingService function parameter above corresponds to the string value you'd like to see in the service field of the Error Reporting payload, as defined by https://cloud.google.com/error-reporting/docs/formatting-error-messages

Also note that, if you enable error reporting, errors and messages of more severe levels go into the error log and will not be displayed in the regular log. The error log name is either defined by the ErrorReportingLogName function or defaults to <regular-log-name>_errors. This fulfills Google's Error Reporting requirement that the log name should have the string err in its name. See more in: https://cloud.google.com/error-reporting/docs/setup/ec2

See GoDoc for a full API listing.

Documentation

Overview

Package sdhook provides a logrus compatible logging hook for Google Stackdriver logging.

Index

Constants

View Source
const (
	// DefaultName is the default name passed to LogName when using serviceClient
	// account credentials.
	DefaultName = "default"
)

Variables

View Source
var MaxLogWriteDuration = 15 * time.Second

Functions

This section is empty.

Types

type Option

type Option func(*StackdriverHook) error

Option represents an option that modifies the Stackdriver hook settings.

func ErrorReportingLogName

func ErrorReportingLogName(name string) Option

ErrorReportingLogName is an option that sets the log name to send with each error message for error reporting. Only used when ErrorReportingService has been set.

func ErrorReportingService

func ErrorReportingService(service string) Option

ErrorReportingService is an option that defines the name of the serviceClient being tracked for Stackdriver error reporting. See: https://cloud.google.com/error-reporting/docs/formatting-error-messages

func ErrorService

func ErrorService(errorService *errorreporting.Client) Option

ErrorService is an option that sets the Google API error reporting serviceClient to use.

func GoogleClientOption

func GoogleClientOption(opts ...option.ClientOption) Option

func GoogleDefaultCredentials

func GoogleDefaultCredentials() Option

GoogleDefaultCredentials returns the token source for "Application Default Credentials".

It looks for credentials in the following places, preferring the first location found:

  1. A JSON file whose path is specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable.
  2. A JSON file in a location known to the gcloud command-line tool. On Windows, this is %APPDATA%/gcloud/application_default_credentials.json. On other systems, $HOME/.config/gcloud/application_default_credentials.json.
  3. On Google App Engine standard first generation runtimes (<= Go 1.9) it uses the appengine.AccessToken function.
  4. On Google Compute Engine, Google App Engine standard second generation runtimes (>= Go 1.11), and Google App Engine flexible environment, it fetches credentials from the metadata server.

func GoogleLoggingAgent

func GoogleLoggingAgent() Option

func Labels

func Labels(labels map[string]string) Option

Labels is an option that sets the labels to send with each log entry.

func Levels

func Levels(levels ...logrus.Level) Option

Levels is an option that sets the logrus levels that the StackdriverHook will create log entries for.

func LogName

func LogName(name string) Option

LogName is an option that sets the log name to send with each log entry.

Log names are specified as "projects/{projectID}/logs/{logName}" if the projectID is set. Otherwise, it's just "{logName}"

func LoggingClient

func LoggingClient(service *logging.Client) Option

LoggingService is an option that sets the Google API logging serviceClient to use.

func MonitoredResource

func MonitoredResource(resource *mrpb.MonitoredResource) Option

MonitoredResource is an option that sets the monitored resource to send with each log entry.

func PartialSuccess

func PartialSuccess(enabled bool) Option

PartialSuccess is an option that toggles whether or not to write partial log entries.

func ProjectID

func ProjectID(projectID string) Option

ProjectID is an option that sets the project ID which is needed for the log name.

func Resource

func Resource(typ ResType, labels map[string]string) Option

Resource is an option that sets the resource information to send with each log entry.

Please see https://cloud.google.com/logging/docs/api/v2/resource-list for the list of labels required per ResType.

func SyncLevels added in v1.1.0

func SyncLevels(levels ...logrus.Level) Option

type ResType

type ResType string

ResType is a monitored resource descriptor type.

See https://cloud.google.com/logging/docs/api/v2/resource-list

const (
	// ResTypeApi, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_api
	ResTypeApi ResType = "api"
	// ResTypeAppScriptFunction, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_app_script_function
	ResTypeAppScriptFunction ResType = "app_script_function"
	// ResTypeAssistantAction, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_assistant_action
	ResTypeAssistantAction ResType = "assistant_action"
	// ResTypeAuditedResource, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_audited_resource
	ResTypeAuditedResource ResType = "audited_resource"
	// ResTypeAwsAlbLoadBalancer, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_aws_alb_load_balancer
	ResTypeAwsAlbLoadBalancer ResType = "aws_alb_load_balancer"
	// ResTypeAwsCloudfrontDistribution, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_aws_cloudfront_distribution
	ResTypeAwsCloudfrontDistribution ResType = "aws_cloudfront_distribution"
	// ResTypeAwsDynamodbTable, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_aws_dynamodb_table
	ResTypeAwsDynamodbTable ResType = "aws_dynamodb_table"
	// ResTypeAwsEbsVolume, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_aws_ebs_volume
	ResTypeAwsEbsVolume ResType = "aws_ebs_volume"
	// ResTypeAwsEc2_instance, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_aws_ec2_instance
	ResTypeAwsEc2_instance ResType = "aws_ec2_instance"
	// ResTypeAwsElasticacheCluster, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_aws_elasticache_cluster
	ResTypeAwsElasticacheCluster ResType = "aws_elasticache_cluster"
	// ResTypeAwsElbLoadBalancer, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_aws_elb_load_balancer
	ResTypeAwsElbLoadBalancer ResType = "aws_elb_load_balancer"
	// ResTypeAwsEmrCluster, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_aws_emr_cluster
	ResTypeAwsEmrCluster ResType = "aws_emr_cluster"
	// ResTypeAwsKinesisStream, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_aws_kinesis_stream
	ResTypeAwsKinesisStream ResType = "aws_kinesis_stream"
	// ResTypeAwsLambdaFunction, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_aws_lambda_function
	ResTypeAwsLambdaFunction ResType = "aws_lambda_function"
	// ResTypeAwsRdsDatabase, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_aws_rds_database
	ResTypeAwsRdsDatabase ResType = "aws_rds_database"
	// ResTypeAwsRedshiftCluster, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_aws_redshift_cluster
	ResTypeAwsRedshiftCluster ResType = "aws_redshift_cluster"
	// ResTypeAwsS3_bucket, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_aws_s3_bucket
	ResTypeAwsS3_bucket ResType = "aws_s3_bucket"
	// ResTypeAwsSes, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_aws_ses
	ResTypeAwsSes ResType = "aws_ses"
	// ResTypeAwsSnsTopic, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_aws_sns_topic
	ResTypeAwsSnsTopic ResType = "aws_sns_topic"
	// ResTypeAwsSqsQueue, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_aws_sqs_queue
	ResTypeAwsSqsQueue ResType = "aws_sqs_queue"
	// ResTypeBigqueryDataset, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_bigquery_dataset
	ResTypeBigqueryDataset ResType = "bigquery_dataset"
	// ResTypeBigqueryProject, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_bigquery_project
	ResTypeBigqueryProject ResType = "bigquery_project"
	// ResTypeBigtableCluster, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_bigtable_cluster
	ResTypeBigtableCluster ResType = "bigtable_cluster"
	// ResTypeBigtableTable, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_bigtable_table
	ResTypeBigtableTable ResType = "bigtable_table"
	// ResTypeBuild, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_build
	ResTypeBuild ResType = "build"
	// ResTypeCloudComposerEnvironment, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_cloud_composer_environment
	ResTypeCloudComposerEnvironment ResType = "cloud_composer_environment"
	// ResTypeCloudDataprocCluster, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_cloud_dataproc_cluster
	ResTypeCloudDataprocCluster ResType = "cloud_dataproc_cluster"
	// ResTypeCloudDataprocJob, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_cloud_dataproc_job
	ResTypeCloudDataprocJob ResType = "cloud_dataproc_job"
	// ResTypeCloudFunction, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_cloud_function
	ResTypeCloudFunction ResType = "cloud_function"
	// ResTypeCloudRunRevision, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_cloud_run_revision
	ResTypeCloudRunRevision ResType = "cloud_run_revision"
	// ResTypeCloudSchedulerJob, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_cloud_scheduler_job
	ResTypeCloudSchedulerJob ResType = "cloud_scheduler_job"
	// ResTypeCloudTasksQueue, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_cloud_tasks_queue
	ResTypeCloudTasksQueue ResType = "cloud_tasks_queue"
	// ResTypeCloudiotDevice, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_cloudiot_device
	ResTypeCloudiotDevice ResType = "cloudiot_device"
	// ResTypeCloudiotDeviceRegistry, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_cloudiot_device_registry
	ResTypeCloudiotDeviceRegistry ResType = "cloudiot_device_registry"
	// ResTypeCloudmlJob, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_cloudml_job
	ResTypeCloudmlJob ResType = "cloudml_job"
	// ResTypeCloudmlModelVersion, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_cloudml_model_version
	ResTypeCloudmlModelVersion ResType = "cloudml_model_version"
	// ResTypeCloudsqlDatabase, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_cloudsql_database
	ResTypeCloudsqlDatabase ResType = "cloudsql_database"
	// ResTypeConsumedApi, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_consumed_api
	ResTypeConsumedApi ResType = "consumed_api"
	// ResTypeCsrRepository, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_csr_repository
	ResTypeCsrRepository ResType = "csr_repository"
	// ResTypeDataflowJob, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_dataflow_job
	ResTypeDataflowJob ResType = "dataflow_job"
	// ResTypeDatastoreRequest, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_datastore_request
	ResTypeDatastoreRequest ResType = "datastore_request"
	// ResTypeDnsManagedZone, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_dns_managed_zone
	ResTypeDnsManagedZone ResType = "dns_managed_zone"
	// ResTypeDnsPolicy, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_dns_policy
	ResTypeDnsPolicy ResType = "dns_policy"
	// ResTypeDnsQuery, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_dns_query
	ResTypeDnsQuery ResType = "dns_query"
	// ResTypeFilestoreInstance, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_filestore_instance
	ResTypeFilestoreInstance ResType = "filestore_instance"
	// ResTypeFirebaseDomain, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_firebase_domain
	ResTypeFirebaseDomain ResType = "firebase_domain"
	// ResTypeFirebaseNamespace, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_firebase_namespace
	ResTypeFirebaseNamespace ResType = "firebase_namespace"
	// ResTypeFirestoreInstance, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_firestore_instance
	ResTypeFirestoreInstance ResType = "firestore_instance"
	// ResTypeGaeApp, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_gae_app
	ResTypeGaeApp ResType = "gae_app"
	// ResTypeGaeInstance, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_gae_instance
	ResTypeGaeInstance ResType = "gae_instance"
	ResTypeGceProject  ResType = "gce_project"
	// ResTypeGceDisk, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_gce_disk
	ResTypeGceDisk ResType = "gce_disk"
	// ResTypeGceInstance, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_gce_instance
	ResTypeGceInstance ResType = "gce_instance"
	// ResTypeGceNodeGroup, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_gce_node_group
	ResTypeGceNodeGroup ResType = "gce_node_group"
	// ResTypeGceNodeTemplate, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_gce_node_template
	ResTypeGceNodeTemplate ResType = "gce_node_template"
	// ResTypeGceResourcePolicy, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_gce_resource_policy
	ResTypeGceResourcePolicy ResType = "gce_resource_policy"
	// ResTypeGceRouter, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_gce_router
	ResTypeGceRouter ResType = "gce_router"
	// ResTypeGcsBucket, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_gcs_bucket
	ResTypeGcsBucket ResType = "gcs_bucket"
	// ResTypeGenericNode, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_generic_node
	ResTypeGenericNode ResType = "generic_node"
	// ResTypeGenericTask, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_generic_task
	ResTypeGenericTask ResType = "generic_task"
	// ResTypeGkeContainer, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_gke_container
	ResTypeGkeContainer ResType = "gke_container"
	// ResTypeGlobal, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_global
	ResTypeGlobal ResType = "global"
	// ResTypeHttpsLbRule, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_https_lb_rule
	ResTypeHttpsLbRule ResType = "https_lb_rule"
	// ResTypeIdentitytoolkitProject, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_identitytoolkit_project
	ResTypeIdentitytoolkitProject ResType = "identitytoolkit_project"
	// ResTypeIdentitytoolkitTenant, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_identitytoolkit_tenant
	ResTypeIdentitytoolkitTenant ResType = "identitytoolkit_tenant"
	// ResTypeInterconnect, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_interconnect
	ResTypeInterconnect ResType = "interconnect"
	// ResTypeInterconnectAttachment, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_interconnect_attachment
	ResTypeInterconnectAttachment ResType = "interconnect_attachment"
	// ResTypeInternalHttpLbRule, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_internal_http_lb_rule
	ResTypeInternalHttpLbRule ResType = "internal_http_lb_rule"
	// ResTypeInternalTcpLbRule, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_internal_tcp_lb_rule
	ResTypeInternalTcpLbRule ResType = "internal_tcp_lb_rule"
	// ResTypeInternalUdpLbRule, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_internal_udp_lb_rule
	ResTypeInternalUdpLbRule ResType = "internal_udp_lb_rule"
	// ResTypeK8s_cluster, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_k8s_cluster
	ResTypeK8s_cluster ResType = "k8s_cluster"
	// ResTypeK8s_container, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_k8s_container
	ResTypeK8s_container ResType = "k8s_container"
	// ResTypeK8s_node, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_k8s_node
	ResTypeK8s_node ResType = "k8s_node"
	// ResTypeK8s_pod, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_k8s_pod
	ResTypeK8s_pod ResType = "k8s_pod"
	// ResTypeKnativeRevision, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_knative_revision
	ResTypeKnativeRevision ResType = "knative_revision"
	// ResTypeL7_lb_rule, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_l7_lb_rule
	ResTypeL7_lb_rule ResType = "l7_lb_rule"
	// ResTypeLoggingExclusion, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_logging_exclusion
	ResTypeLoggingExclusion ResType = "logging_exclusion"
	// ResTypeLoggingSink, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_logging_sink
	ResTypeLoggingSink ResType = "logging_sink"
	// ResTypeMetric, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_metric
	ResTypeMetric ResType = "metric"
	// ResTypeMicrosoftAdDomain, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_microsoft_ad_domain
	ResTypeMicrosoftAdDomain ResType = "microsoft_ad_domain"
	// ResTypeNatGateway, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_nat_gateway
	ResTypeNatGateway ResType = "nat_gateway"
	// ResTypeNetappCloudVolume, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_netapp_cloud_volume
	ResTypeNetappCloudVolume ResType = "netapp_cloud_volume"
	// ResTypeNetworkSecurityPolicy, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_network_security_policy
	ResTypeNetworkSecurityPolicy ResType = "network_security_policy"
	// ResTypePubsubSnapshot, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_pubsub_snapshot
	ResTypePubsubSnapshot ResType = "pubsub_snapshot"
	// ResTypePubsubSubscription, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_pubsub_subscription
	ResTypePubsubSubscription ResType = "pubsub_subscription"
	// ResTypePubsubTopic, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_pubsub_topic
	ResTypePubsubTopic ResType = "pubsub_topic"
	// ResTypeRecommender, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_recommender
	ResTypeRecommender ResType = "recommender"
	// ResTypeRedisInstance, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_redis_instance
	ResTypeRedisInstance ResType = "redis_instance"
	// ResTypeSpannerInstance, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_spanner_instance
	ResTypeSpannerInstance ResType = "spanner_instance"
	// ResTypeTcpLbRule, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_tcp_lb_rule
	ResTypeTcpLbRule ResType = "tcp_lb_rule"
	// ResTypeTcpSslProxyRule, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_tcp_ssl_proxy_rule
	ResTypeTcpSslProxyRule ResType = "tcp_ssl_proxy_rule"
	// ResTypeTpuWorker, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_tpu_worker
	ResTypeTpuWorker ResType = "tpu_worker"
	// ResTypeUdpLbRule, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_udp_lb_rule
	ResTypeUdpLbRule ResType = "udp_lb_rule"
	// ResTypeUptimeUrl, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_uptime_url
	ResTypeUptimeUrl ResType = "uptime_url"
	// ResTypeVpnGateway, for description and list of labels https://cloud.google.com/monitoring/api/resources#tag_vpn_gateway
	ResTypeVpnGateway ResType = "vpn_gateway"
)

type StackdriverHook

type StackdriverHook struct {
	// contains filtered or unexported fields
}

StackdriverHook provides a logrus hook to Google Stackdriver logging.

func New

func New(opts ...Option) (*StackdriverHook, error)

New creates a StackdriverHook using the provided options that is suitible for using with logrus for logging to Google Stackdriver.

func (*StackdriverHook) Fire

func (sh *StackdriverHook) Fire(entry *logrus.Entry) error

Fire writes the message to the Stackdriver entry serviceClient.

func (*StackdriverHook) Levels

func (sh *StackdriverHook) Levels() []logrus.Level

Levels returns the logrus levels that this hook is applied to. This can be set using the Levels Option.

func (*StackdriverHook) Wait

func (sh *StackdriverHook) Wait()

Wait will return after all subroutines have returned. Use in conjunction with logrus return handling to ensure all of your logs are delivered before your program exits. `logrus.RegisterExitHandler(h.Wait)`

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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