Documentation ¶
Overview ¶
Package sdhook provides a Google Stackdriver logging hook for use with logrus.
Index ¶
- type Hook
- type Option
- func EntriesService(service *logging.EntriesService) Option
- func ErrorReportingLogName(name string) Option
- func ErrorReportingService(service string) Option
- func ErrorService(errorService *errorReporting.Service) Option
- func GoogleComputeCredentials(serviceAccount string) Option
- func GoogleCredentials(credentials *google.Credentials) Option
- func GoogleLoggingAgent() Option
- func GoogleServiceAccountCredentialsFile(path string) Option
- func GoogleServiceAccountCredentialsJSON(buf []byte) Option
- func HTTPClient(client *http.Client) Option
- func Labels(labels map[string]string) Option
- func Levels(levels ...logrus.Level) Option
- func LogName(name string) Option
- func LoggingService(service *logging.Service) Option
- func MonitoredResource(resource *logging.MonitoredResource) Option
- func PartialSuccess(enabled bool) Option
- func ProjectID(projectID string) Option
- func Resource(typ ResType, labels map[string]string) Option
- type ResType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hook ¶
type Hook struct {
// contains filtered or unexported fields
}
Hook provides a Google Stackdriver logging hook for use with logrus.
func New ¶
New creates a StackdriverHook using the provided options that is suitible for using with logrus for logging to Google Stackdriver.
type Option ¶
Option represents an option that modifies the Stackdriver hook settings.
func EntriesService ¶
func EntriesService(service *logging.EntriesService) Option
EntriesService is an option that sets the Google API entry service to use with Stackdriver.
func ErrorReportingLogName ¶
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 ¶
ErrorReportingService is an option that defines the name of the service being tracked for Stackdriver error reporting. See: https://cloud.google.com/error-reporting/docs/formatting-error-messages
func ErrorService ¶
func ErrorService(errorService *errorReporting.Service) Option
ErrorService is an option that sets the Google API error reporting service to use.
func GoogleComputeCredentials ¶
GoogleComputeCredentials is an option that loads the Google Service Account credentials from the GCE metadata associated with the GCE compute instance. If serviceAccount is empty, then the default service account credentials associated with the GCE instance will be used.
func GoogleCredentials ¶
func GoogleCredentials(credentials *google.Credentials) Option
func GoogleLoggingAgent ¶
func GoogleLoggingAgent() Option
func GoogleServiceAccountCredentialsFile ¶
GoogleServiceAccountCredentialsFile is an option that loads Google Service Account credentials for use with the StackdriverHook from the specified file.
Google Service Account credentials can be downloaded from the Google Cloud console: https://console.cloud.google.com/iam-admin/serviceaccounts/
func GoogleServiceAccountCredentialsJSON ¶
GoogleServiceAccountCredentialsJSON is an option that creates the Stackdriver logging service using the supplied Google service account credentials.
Google Service Account credentials can be downloaded from the Google Cloud console: https://console.cloud.google.com/iam-admin/serviceaccounts/
func HTTPClient ¶
HTTPClient is an option that sets the http.Client to be used when creating the Stackdriver service.
func Levels ¶
Levels is an option that sets the logrus levels that the StackdriverHook will create log entries for.
func LogName ¶
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 LoggingService ¶
LoggingService is an option that sets the Google API logging service to use.
func MonitoredResource ¶
func MonitoredResource(resource *logging.MonitoredResource) Option
MonitoredResource is an option that sets the monitored resource to send with each log entry.
func PartialSuccess ¶
PartialSuccess is an option that toggles whether or not to write partial log entries.
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 ResType = "api" ResTypeAppScriptFunction ResType = "app_script_function" ResTypeAwsEc2Instance ResType = "aws_ec2_instance" ResTypeBigqueryResource ResType = "bigquery_resource" ResTypeBuild ResType = "build" ResTypeClientAuthConfigBrand ResType = "client_auth_config_brand" ResTypeClientAuthConfigClient ResType = "client_auth_config_client" ResTypeCloudDebuggerResource ResType = "cloud_debugger_resource" ResTypeCloudFunction ResType = "cloud_function" ResTypeCloudRunRevision ResType = "cloud_run_revision" ResTypeCloudsqlDatabase ResType = "cloudsql_database" ResTypeContainer ResType = "container" ResTypeDataflowStep ResType = "dataflow_step" ResTypeDataprocCluster ResType = "dataproc_cluster" ResTypeDeployment ResType = "deployment" ResTypeDeploymentManagerType ResType = "deployment_manager_type" ResTypeDNSManagedZone ResType = "dns_managed_zone" ResTypeGaeApp ResType = "gae_app" ResTypeGceAutoscaler ResType = "gce_autoscaler" ResTypeGceBackendService ResType = "gce_backend_service" ResTypeGceDisk ResType = "gce_disk" ResTypeGceFirewallRule ResType = "gce_firewall_rule" ResTypeGceForwardingRule ResType = "gce_forwarding_rule" ResTypeGceHealthCheck ResType = "gce_health_check" ResTypeGceImage ResType = "gce_image" ResTypeGceInstance ResType = "gce_instance" ResTypeGceInstanceGroup ResType = "gce_instance_group" ResTypeGceInstanceGroupManager ResType = "gce_instance_group_manager" ResTypeGceInstanceTemplate ResType = "gce_instance_template" ResTypeGceNetwork ResType = "gce_network" ResTypeGceOperation ResType = "gce_operation" ResTypeGceProject ResType = "gce_project" ResTypeGceReservedAddress ResType = "gce_reserved_address" ResTypeGceRoute ResType = "gce_route" ResTypeGceRouter ResType = "gce_router" ResTypeGceSnapshot ResType = "gce_snapshot" ResTypeGceSslCertificate ResType = "gce_ssl_certificate" ResTypeGceSubnetwork ResType = "gce_subnetwork" ResTypeGceTargetHTTPProxy ResType = "gce_target_http_proxy" ResTypeGceTargetHTTPSProxy ResType = "gce_target_https_proxy" ResTypeGceTargetPool ResType = "gce_target_pool" ResTypeGceURLMap ResType = "gce_url_map" ResTypeGcsBucket ResType = "gcs_bucket" ResTypeGkeCluster ResType = "gke_cluster" ResTypeGlobal ResType = "global" ResTypeHTTPLoadBalancer ResType = "http_load_balancer" ResTypeLoggingLog ResType = "logging_log" ResTypeLoggingSink ResType = "logging_sink" ResTypeMetric ResType = "metric" ResTypeMlJob ResType = "ml_job" ResTypeOrganization ResType = "organization" ResTypeProject ResType = "project" ResTypeServiceAccount ResType = "service_account" ResTypeTestserviceMatrix ResType = "testservice_matrix" ResTypeVpnGateway ResType = "vpn_gateway" )
ResType values.