module Google::Cloud

Public Class Methods

logging(project_id = nil, credentials = nil, scope: nil, timeout: nil) click to toggle source

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 {file:AUTHENTICATION.md Authentication Guide}.

@param [String] project_id Project identifier for the Stackdriver Logging

service you are connecting to. If not present, the default project for
the credentials is used.

@param [String, Hash, Google::Auth::Credentials] credentials The path to

the keyfile as a String, the contents of the keyfile as a Hash, or a
Google::Auth::Credentials object. (See {Logging::Credentials})

@param [String, Array<String>] scope 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](https://developers.google.com/identity/protocols/OAuth2).

The default scope is:

* `https://www.googleapis.com/auth/logging.admin`

@param [Integer] timeout Default timeout to use in requests. Optional.

@return [Google::Cloud::Logging::Project]

@example

require "google/cloud"

logging = Google::Cloud.logging

entries = logging.entries
entries.each do |e|
  puts "[#{e.timestamp}] #{e.log_name} #{e.payload.inspect}"
end
# File lib/google-cloud-logging.rb, line 109
def self.logging project_id = nil, credentials = nil, scope: nil, timeout: nil
  require "google/cloud/logging"
  Google::Cloud::Logging.new project_id: project_id,
                             credentials: credentials,
                             scope: scope, timeout: timeout
end

Public Instance Methods

logging(scope: nil, timeout: nil) click to toggle source

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 {file:AUTHENTICATION.md Authentication Guide}.

@param [String, Array<String>] scope 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](https://developers.google.com/identity/protocols/OAuth2).

The default scope is:

* `https://www.googleapis.com/auth/logging.admin`

@param [Integer] timeout Default timeout to use in requests. Optional.

@return [Google::Cloud::Logging::Project]

@example

require "google/cloud"

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

entries = logging.entries
entries.each do |e|
  puts "[#{e.timestamp}] #{e.log_name} #{e.payload.inspect}"
end

@example 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
# File lib/google-cloud-logging.rb, line 67
def logging scope: nil, timeout: nil
  timeout ||= @timeout
  Google::Cloud.logging @project, @keyfile, scope:   scope,
                                            timeout: timeout
end