Module: Google::Cloud

Defined in:
lib/google-cloud-logging.rb,
lib/google/cloud/logging.rb,
lib/google/cloud/logging/sink.rb,
lib/google/cloud/logging/entry.rb,
lib/google/cloud/logging/logger.rb,
lib/google/cloud/logging/metric.rb,
lib/google/cloud/logging/project.rb,
lib/google/cloud/logging/service.rb,
lib/google/cloud/logging/version.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/credentials.rb,
lib/google/cloud/logging/metric/list.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/resource_descriptor/list.rb

Defined Under Namespace

Modules: Logging

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.logging(project = nil, keyfile = nil, scope: nil, retries: nil, timeout: 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.

Examples:

require "google/cloud/logging"

gcloud = Google::Cloud.new
logging = gcloud.logging
# ...

Parameters:

  • project (String) (defaults to: nil)

    Project identifier for the Stackdriver Logging service.

  • keyfile (String, Hash) (defaults to: nil)

    Keyfile downloaded from Google Cloud. If file path the file must be readable.

  • scope (String, Array<String>)

    The OAuth 2.0 scopes controlling the set of resources and operations that the connection can access. See Using OAuth 2.0 to Access Google APIs.

    The default scope is:

    • https://www.googleapis.com/auth/logging.admin
  • retries (Integer)

    Number of times to retry requests on server error. The default value is 3. Optional.

  • timeout (Integer)

    Default timeout to use in requests. Optional.

Returns:



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/google-cloud-logging.rb', line 99

def self.logging project = nil, keyfile = nil, scope: nil, retries: nil,
                 timeout: nil
  require "google/cloud/logging"
  project ||= Google::Cloud::Logging::Project.default_project
  project = project.to_s # Always cast to a string
  fail ArgumentError, "project is missing" if project.empty?

  if keyfile.nil?
    credentials = Google::Cloud::Logging::Credentials.default(
      scope: scope)
  else
    credentials = Google::Cloud::Logging::Credentials.new(
      keyfile, scope: scope)
  end

  Google::Cloud::Logging::Project.new(
    Google::Cloud::Logging::Service.new(
      project, credentials, retries: retries, timeout: timeout))
end

Instance Method Details

#logging(scope: nil, retries: nil, timeout: 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.

Examples:

require "google/cloud"

gcloud = Google::Cloud.new
logging = gcloud.logging
# ...

The default scope can be overridden with the scope option:

require "google/cloud"

gcloud  = Google::Cloud.new
platform_scope = "https://www.googleapis.com/auth/cloud-platform"
logging = gcloud.logging scope: platform_scope

Parameters:

  • scope (String, Array<String>)

    The OAuth 2.0 scopes controlling the set of resources and operations that the connection can access. See Using OAuth 2.0 to Access Google APIs.

    The default scope is:

    • https://www.googleapis.com/auth/logging.admin
  • retries (Integer)

    Number of times to retry requests on server error. The default value is 3. Optional.

  • timeout (Integer)

    Default timeout to use in requests. Optional.

Returns:



61
62
63
64
65
# File 'lib/google-cloud-logging.rb', line 61

def logging scope: nil, retries: nil, timeout: nil
  Google::Cloud.logging @project, @keyfile, scope: scope,
                                            retries: (retries || @retries),
                                            timeout: (timeout || @timeout)
end