Class: Gcloud::Logging::Sink

Inherits:
Object
  • Object
show all
Defined in:
lib/gcloud/logging/sink.rb,
lib/gcloud/logging/sink/list.rb

Overview

Sink

Used to export log entries outside Cloud Logging.

Examples:

require "gcloud"

gcloud = Gcloud.new
logging = gcloud.logging
sink = logging.sink "severe_errors"

Defined Under Namespace

Classes: List

Instance Method Summary collapse

Instance Method Details

#deleteBoolean

Permanently deletes the logs-based sink.

Examples:

require "gcloud"

gcloud = Gcloud.new
logging = gcloud.logging
sink = logging.sink "severe_errors"
sink.delete

Returns:

  • (Boolean)

    Returns true if the sink was deleted.


183
184
185
186
187
188
189
190
191
# File 'lib/gcloud/logging/sink.rb', line 183

def delete
  ensure_connection!
  resp = connection.delete_sink name
  if resp.success?
    true
  else
    fail ApiError.from_response(resp)
  end
end

#destinationObject

The export destination. See Exporting Logs With Sinks.


64
65
66
# File 'lib/gcloud/logging/sink.rb', line 64

def destination
  @gapi["destination"]
end

#destination=(destination) ⇒ Object

Updates the export destination. See Exporting Logs With Sinks.


71
72
73
# File 'lib/gcloud/logging/sink.rb', line 71

def destination= destination
  @gapi["destination"] = destination
end

#filterObject

An advanced logs filter that defines the log entries to be exported. The filter must be consistent with the log entry format designed by the version parameter, regardless of the format of the log entry that was originally written to Cloud Logging.


82
83
84
# File 'lib/gcloud/logging/sink.rb', line 82

def filter
  @gapi["filter"]
end

#filter=(filter) ⇒ Object

Updates the advanced logs filter that defines the log entries to be exported. The filter must be consistent with the log entry format designed by the version parameter, regardless of the format of the log entry that was originally written to Cloud Logging.


93
94
95
# File 'lib/gcloud/logging/sink.rb', line 93

def filter= filter
  @gapi["filter"] = filter
end

#nameObject

The client-assigned sink identifier. Sink identifiers are limited to 1000 characters and can include only the following characters: A-Z, a-z, 0-9, and the special characters _-..


57
58
59
# File 'lib/gcloud/logging/sink.rb', line 57

def name
  @gapi["name"]
end

#reload!Object Also known as: refresh!

Reloads the logs-based sink with current data from the Logging service.


159
160
161
162
163
164
165
166
167
# File 'lib/gcloud/logging/sink.rb', line 159

def reload!
  ensure_connection!
  resp = connection.get_sink name
  if resp.success?
    @gapi = resp.data
  else
    fail ApiError.from_response(resp)
  end
end

#saveObject

Updates the logs-based sink.

Examples:

require "gcloud"

gcloud = Gcloud.new
logging = gcloud.logging
sink = logging.sink "severe_errors"
sink.filter = "logName:syslog AND severity>=ERROR"
sink.save

146
147
148
149
150
151
152
153
154
# File 'lib/gcloud/logging/sink.rb', line 146

def save
  ensure_connection!
  resp = connection.update_sink name, destination, filter, version
  if resp.success?
    @gapi = resp.data
  else
    fail ApiError.from_response(resp)
  end
end

#unspecified?Boolean

Helper to determine if the sink's version is VERSION_FORMAT_UNSPECIFIED.

Returns:

  • (Boolean)

118
119
120
# File 'lib/gcloud/logging/sink.rb', line 118

def unspecified?
  version == VERSIONS[:unspecified]
end

#v1?Boolean

Helper to determine if the sink's version is V1.

Returns:

  • (Boolean)

130
131
132
# File 'lib/gcloud/logging/sink.rb', line 130

def v1?
  version == VERSIONS[:v1]
end

#v2?Boolean

Helper to determine if the sink's version is V2.

Returns:

  • (Boolean)

124
125
126
# File 'lib/gcloud/logging/sink.rb', line 124

def v2?
  version == VERSIONS[:v2]
end

#versionObject

The log entry version used when exporting log entries from this sink. This version does not have to correspond to the version of the log entry when it was written to Cloud Logging.


101
102
103
# File 'lib/gcloud/logging/sink.rb', line 101

def version
  @gapi["outputVersionFormat"]
end

#version=(version) ⇒ Object

Updates the log entry version used when exporting log entries from this sink. This version does not have to correspond to the version of the log entry when it was written to Cloud Logging. Accepted values are :unspecified, :v2, and :v1.


110
111
112
113
# File 'lib/gcloud/logging/sink.rb', line 110

def version= version
  version = VERSIONS[version] if VERSIONS[version]
  @gapi["outputVersionFormat"] = version
end