Module: Google::Cloud::Logging
- Defined in:
- lib/google/cloud/logging.rb,
lib/google/cloud/logging/sink.rb,
lib/google/cloud/logging/entry.rb,
lib/google/cloud/logging/rails.rb,
lib/google/cloud/logging/errors.rb,
lib/google/cloud/logging/logger.rb,
lib/google/cloud/logging/metric.rb,
lib/google/cloud/logging/convert.rb,
lib/google/cloud/logging/project.rb,
lib/google/cloud/logging/service.rb,
lib/google/cloud/logging/version.rb,
lib/google/cloud/logging/log/list.rb,
lib/google/cloud/logging/resource.rb,
lib/google/cloud/logging/sink/list.rb,
lib/google/cloud/logging/entry/list.rb,
lib/google/cloud/logging/middleware.rb,
lib/google/cloud/logging/credentials.rb,
lib/google/cloud/logging/metric/list.rb,
lib/google/cloud/logging/async_writer.rb,
lib/google/cloud/logging/entry/operation.rb,
lib/google/cloud/logging/entry/http_request.rb,
lib/google/cloud/logging/resource_descriptor.rb,
lib/google/cloud/logging/entry/source_location.rb,
lib/google/cloud/logging/resource_descriptor/list.rb
Overview
Stackdriver Logging
The Stackdriver Logging service collects and stores logs from applications and services on the Google Cloud Platform, giving you fine-grained, programmatic control over your projects' logs. You can use the Stackdriver Logging API to:
- Read and filter log entries
- Export your log entries to Cloud Storage, BigQuery, or Cloud Pub/Sub
- Create logs-based metrics for use in Cloud Monitoring
- Write log entries
For general information about Stackdriver Logging, read Stackdriver Logging Documentation.
Defined Under Namespace
Classes: AsyncWriteEntriesError, AsyncWriter, AsyncWriterError, Credentials, Entry, Log, Logger, Metric, Middleware, Project, Railtie, Resource, ResourceDescriptor, Sink
Constant Summary collapse
- DEFAULT_LOG_NAME =
Default log name to be used for Stackdriver Logging
Middleware::DEFAULT_LOG_NAME
- VERSION =
"2.5.0".freeze
Class Method Summary collapse
-
.configure {|Google::Cloud.configure.logging| ... } ⇒ Google::Cloud::Config
Configure the Google::Cloud::Logging::Middleware when used in a Rack-based application.
-
.new(project_id: nil, credentials: nil, scope: nil, timeout: nil, endpoint: nil, project: nil, keyfile: nil) ⇒ Google::Cloud::Logging::Project
Creates a new object for connecting to the Stackdriver Logging service.
Class Method Details
.configure {|Google::Cloud.configure.logging| ... } ⇒ Google::Cloud::Config
Configure the Google::Cloud::Logging::Middleware when used in a Rack-based application.
The following Stackdriver Logging configuration parameters are supported:
project_id
- (String) Project identifier for the Stackdriver Logging service you are connecting to. (The parameterproject
is considered deprecated, but may also be used.)credentials
- (String, Hash, Google::Auth::Credentials) The path to the keyfile as a String, the contents of the keyfile as a Hash, or a Google::Auth::Credentials object. (See Credentials) (The parameterkeyfile
is considered deprecated, but may also be used.)scope
- (String, Array) The OAuth 2.0 scopes controlling the set of resources and operations that the connection can access. quota_project
- (String) The project ID for a project that can be used by client libraries for quota and billing purposes.timeout
- (Integer) Default timeout to use in requests.endpoint
- (String) Override of the endpoint host name, ornil
to use the default endpoint.log_name
- (String) Name of the application log file. Default:"ruby_app_log"
log_name_map
- (Hash) Map specific request routes to other log. Default:{ "/_ah/health" => "ruby_health_check_log" }
monitored_resource.type
(String) Resource type name. See full list. Self discovered on GCP.monitored_resource.labels
-(Hash) Resource labels. See full list. Self discovered on GCP.labels
- (Hash) User defined labels. AHash
of label names to string label values or callables/Proc
which are functions of the Rack environment.set_default_logger_on_rails_init
- (Boolean) Whether Google Cloud Logging Logger should be allowed to start background threads and open gRPC connections during Rails initialization. This should only be used with a non-forking web server. Web servers such as Puma and Unicorn should not set this, and instead set the Rails logger to a Google Cloud Logging Logger object on the worker process by calling Google::Cloud::Logging::Railtie.set_default_logger at the appropriate time, such as a post-fork hook.on_error
- (Proc) A Proc to be run when an error is encountered on a background thread. The Proc must take the error object as the single argument. (See Google::Cloud::Logging::AsyncWriter#on_error.)
See the Configuration Guide for full configuration parameters.
164 165 166 167 168 |
# File 'lib/google/cloud/logging.rb', line 164 def self.configure yield Google::Cloud.configure.logging if block_given? Google::Cloud.configure.logging end |
.new(project_id: nil, credentials: nil, scope: nil, timeout: nil, endpoint: nil, project: nil, keyfile: nil) ⇒ Google::Cloud::Logging::Project
Creates a new object for connecting to the Stackdriver Logging service. Each call creates a new connection.
For more information on connecting to Google Cloud see the Authentication Guide.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/google/cloud/logging.rb', line 84 def self.new project_id: nil, credentials: nil, scope: nil, timeout: nil, endpoint: nil, project: nil, keyfile: nil project_id ||= project || default_project_id scope ||= configure.scope timeout ||= configure.timeout endpoint ||= configure.endpoint credentials ||= keyfile || default_credentials(scope: scope) unless credentials.is_a? Google::Auth::Credentials credentials = Logging::Credentials.new credentials, scope: scope end if credentials.respond_to? :project_id project_id ||= credentials.project_id end project_id = project_id.to_s # Always cast to a string raise ArgumentError, "project_id is missing" if project_id.empty? service = Logging::Service.new project_id, credentials, host: endpoint, timeout: timeout Logging::Project.new service end |