Class: Google::Cloud::Logging::Entry
- Inherits:
-
Object
- Object
- Google::Cloud::Logging::Entry
- Defined in:
- lib/google/cloud/logging/entry.rb,
lib/google/cloud/logging/entry/list.rb,
lib/google/cloud/logging/entry/operation.rb,
lib/google/cloud/logging/entry/http_request.rb,
lib/google/cloud/logging/entry/source_location.rb
Overview
Entry
An individual entry in a log.
Each log entry is composed of metadata and a payload. The metadata includes standard information used by Stackdriver Logging, such as when the entry was created and where it came from. The payload is the event record. Traditionally this is a message string, but in Stackdriver Logging it can also be a JSON or protocol buffer object. A single log can have entries with different payload types.
A log is a named collection of entries. Logs can be produced by Google
Cloud Platform services, by third-party services, or by your
applications. For example, the log compute.googleapis.com/activity_log
is produced by Google Compute Engine. Logs are simply referenced by name
in google-cloud. There is no Log
type in google-cloud or Log
resource in the Stackdriver Logging API.
Defined Under Namespace
Classes: HttpRequest, List, Operation, SourceLocation
Instance Attribute Summary collapse
-
#http_request ⇒ Google::Cloud::Logging::Entry::HttpRequest
readonly
Information about the HTTP request associated with this log entry, if applicable.
-
#insert_id ⇒ String
A unique ID for the log entry.
-
#labels ⇒ Hash
A set of user-defined data that provides additional information about the log entry.
-
#log_name ⇒ Object
The resource name of the log to which this log entry belongs.
-
#operation ⇒ Google::Cloud::Logging::Entry::Operation
readonly
Information about an operation associated with the log entry, if applicable.
-
#payload ⇒ String, Hash
The log entry payload, represented as either a string, a hash (JSON), or a hash (protocol buffer).
-
#resource ⇒ Google::Cloud::Logging::Resource
The monitored resource associated with this log entry.
-
#severity ⇒ Symbol
The severity level of the log entry.
-
#source_location ⇒ Google::Cloud::Logging::Entry::SourceLocation
readonly
Source code location information associated with the log entry, if any.
-
#timestamp ⇒ Time
The time the event described by the log entry occurred.
-
#trace ⇒ String
Resource name of the trace associated with the log entry, if any.
-
#trace_sampled ⇒ Boolean
The sampling decision of the trace associated with the log entry.
Class Method Summary collapse
-
.insert_id ⇒ String
Generate a pseudo-random, 16-character ID suitable for use as the log entry's #insert_id.
Instance Method Summary collapse
-
#alert! ⇒ Object
Sets the severity level to
:ALERT
. -
#alert? ⇒ Boolean
Returns
true
if the severity level is:ALERT
. -
#critical! ⇒ Object
Sets the severity level to
:CRITICAL
. -
#critical? ⇒ Boolean
Returns
true
if the severity level is:CRITICAL
. -
#debug! ⇒ Object
Sets the severity level to
:DEBUG
. -
#debug? ⇒ Boolean
Returns
true
if the severity level is:DEBUG
. -
#default! ⇒ Object
Sets the severity level to
:DEFAULT
. -
#default? ⇒ Boolean
Returns
true
if the severity level is:DEFAULT
. -
#emergency! ⇒ Object
Sets the severity level to
:EMERGENCY
. -
#emergency? ⇒ Boolean
Returns
true
if the severity level is:EMERGENCY
. -
#error! ⇒ Object
Sets the severity level to
:ERROR
. -
#error? ⇒ Boolean
Returns
true
if the severity level is:ERROR
. -
#info! ⇒ Object
Sets the severity level to
:INFO
. -
#info? ⇒ Boolean
Returns
true
if the severity level is:INFO
. -
#initialize ⇒ Entry
constructor
Create a new Entry instance.
-
#notice! ⇒ Object
Sets the severity level to
:NOTICE
. -
#notice? ⇒ Boolean
Returns
true
if the severity level is:NOTICE
. -
#warning! ⇒ Object
Sets the severity level to
:WARNING
. -
#warning? ⇒ Boolean
Returns
true
if the severity level is:WARNING
.
Constructor Details
#initialize ⇒ Entry
Create a new Entry instance. The #resource attribute is pre-populated with a new Resource instance. See also Project#entry.
93 94 95 96 97 98 99 100 101 |
# File 'lib/google/cloud/logging/entry.rb', line 93 def initialize @labels = {} @resource = Resource.new @http_request = HttpRequest.new @operation = Operation.new @severity = :DEFAULT @source_location = SourceLocation.new @insert_id = Entry.insert_id end |
Instance Attribute Details
#http_request ⇒ Google::Cloud::Logging::Entry::HttpRequest (readonly)
Information about the HTTP request associated with this log entry, if applicable.
375 376 377 |
# File 'lib/google/cloud/logging/entry.rb', line 375 def http_request @http_request end |
#insert_id ⇒ String
A unique ID for the log entry. If you provide this field, the logging service considers other log entries in the same log with the same ID as duplicates which can be removed. If omitted, Stackdriver Logging will generate a unique ID for this log entry.
357 358 359 |
# File 'lib/google/cloud/logging/entry.rb', line 357 def insert_id @insert_id end |
#labels ⇒ Hash
A set of user-defined data that provides additional information about the log entry.
363 364 365 |
# File 'lib/google/cloud/logging/entry.rb', line 363 def labels @labels end |
#log_name ⇒ Object
The resource name of the log to which this log entry belongs. The
format of the name is projects/<project-id>/logs/<log-id>
. e.g.
projects/my-projectid/logs/my_app_log
and
projects/1234567890/logs/library.googleapis.com%2Fbook_log
The log ID part of resource name must be less than 512 characters long
and can only include the following characters: upper and lower case
alphanumeric characters: [A-Za-z0-9]
; and punctuation characters:
forward-slash (/
), underscore (_
), hyphen (-
), and period (.
).
Forward-slash (/
) characters in the log ID must be URL-encoded.
114 115 116 |
# File 'lib/google/cloud/logging/entry.rb', line 114 def log_name @log_name end |
#operation ⇒ Google::Cloud::Logging::Entry::Operation (readonly)
Information about an operation associated with the log entry, if applicable.
381 382 383 |
# File 'lib/google/cloud/logging/entry.rb', line 381 def operation @operation end |
#payload ⇒ String, Hash
The log entry payload, represented as either a string, a hash (JSON), or a hash (protocol buffer).
369 370 371 |
# File 'lib/google/cloud/logging/entry.rb', line 369 def payload @payload end |
#resource ⇒ Google::Cloud::Logging::Resource
The monitored resource associated with this log entry. Example: a log entry that reports a database error would be associated with the monitored resource designating the particular database that reported the error.
122 123 124 |
# File 'lib/google/cloud/logging/entry.rb', line 122 def resource @resource end |
#severity ⇒ Symbol
The severity level of the log entry. The default value is :DEFAULT
.
133 134 135 |
# File 'lib/google/cloud/logging/entry.rb', line 133 def severity @severity end |
#source_location ⇒ Google::Cloud::Logging::Entry::SourceLocation (readonly)
Source code location information associated with the log entry, if any.
396 397 398 |
# File 'lib/google/cloud/logging/entry.rb', line 396 def source_location @source_location end |
#timestamp ⇒ Time
The time the event described by the log entry occurred. If omitted, Stackdriver Logging will use the time the log entry is written.
128 129 130 |
# File 'lib/google/cloud/logging/entry.rb', line 128 def @timestamp end |
#trace ⇒ String
Resource name of the trace associated with the log entry, if any. If
it contains a relative resource name, the name is assumed to be
relative to //tracing.googleapis.com
. Example:
projects/my-projectid/traces/06796866738c859f2f19b7cfb3214824
Optional.
390 391 392 |
# File 'lib/google/cloud/logging/entry.rb', line 390 def trace @trace end |
#trace_sampled ⇒ Boolean
The sampling decision of the trace associated with the log entry.
Optional. A true
value means that the trace resource name in the
trace
field was sampled for storage in a trace backend. A false
means that the trace was not sampled for storage when this log entry
was written, or the sampling decision was unknown at the time. A
non-sampled trace
value is still useful as a request correlation
identifier. The default is false
.
407 408 409 |
# File 'lib/google/cloud/logging/entry.rb', line 407 def trace_sampled @trace_sampled end |
Class Method Details
.insert_id ⇒ String
Generate a pseudo-random, 16-character ID suitable for use as the log entry's #insert_id.
85 86 87 |
# File 'lib/google/cloud/logging/entry.rb', line 85 def self.insert_id rand(36**16).to_s 36 end |
Instance Method Details
#alert! ⇒ Object
Sets the severity level to :ALERT
.
323 324 325 |
# File 'lib/google/cloud/logging/entry.rb', line 323 def alert! self.severity = :ALERT end |
#alert? ⇒ Boolean
Returns true
if the severity level is :ALERT
.
305 306 307 |
# File 'lib/google/cloud/logging/entry.rb', line 305 def alert? severity == :ALERT end |
#critical! ⇒ Object
Sets the severity level to :CRITICAL
.
299 300 301 |
# File 'lib/google/cloud/logging/entry.rb', line 299 def critical! self.severity = :CRITICAL end |
#critical? ⇒ Boolean
Returns true
if the severity level is :CRITICAL
.
281 282 283 |
# File 'lib/google/cloud/logging/entry.rb', line 281 def critical? severity == :CRITICAL end |
#debug! ⇒ Object
Sets the severity level to :DEBUG
.
179 180 181 |
# File 'lib/google/cloud/logging/entry.rb', line 179 def debug! self.severity = :DEBUG end |
#debug? ⇒ Boolean
Returns true
if the severity level is :DEBUG
.
161 162 163 |
# File 'lib/google/cloud/logging/entry.rb', line 161 def debug? severity == :DEBUG end |
#default! ⇒ Object
Sets the severity level to :DEFAULT
.
155 156 157 |
# File 'lib/google/cloud/logging/entry.rb', line 155 def default! self.severity = :DEFAULT end |
#default? ⇒ Boolean
Returns true
if the severity level is :DEFAULT
.
137 138 139 |
# File 'lib/google/cloud/logging/entry.rb', line 137 def default? severity == :DEFAULT end |
#emergency! ⇒ Object
Sets the severity level to :EMERGENCY
.
347 348 349 |
# File 'lib/google/cloud/logging/entry.rb', line 347 def emergency! self.severity = :EMERGENCY end |
#emergency? ⇒ Boolean
Returns true
if the severity level is :EMERGENCY
.
329 330 331 |
# File 'lib/google/cloud/logging/entry.rb', line 329 def emergency? severity == :EMERGENCY end |
#error! ⇒ Object
Sets the severity level to :ERROR
.
275 276 277 |
# File 'lib/google/cloud/logging/entry.rb', line 275 def error! self.severity = :ERROR end |
#error? ⇒ Boolean
Returns true
if the severity level is :ERROR
.
257 258 259 |
# File 'lib/google/cloud/logging/entry.rb', line 257 def error? severity == :ERROR end |
#info! ⇒ Object
Sets the severity level to :INFO
.
203 204 205 |
# File 'lib/google/cloud/logging/entry.rb', line 203 def info! self.severity = :INFO end |
#info? ⇒ Boolean
Returns true
if the severity level is :INFO
.
185 186 187 |
# File 'lib/google/cloud/logging/entry.rb', line 185 def info? severity == :INFO end |
#notice! ⇒ Object
Sets the severity level to :NOTICE
.
227 228 229 |
# File 'lib/google/cloud/logging/entry.rb', line 227 def notice! self.severity = :NOTICE end |
#notice? ⇒ Boolean
Returns true
if the severity level is :NOTICE
.
209 210 211 |
# File 'lib/google/cloud/logging/entry.rb', line 209 def notice? severity == :NOTICE end |
#warning! ⇒ Object
Sets the severity level to :WARNING
.
251 252 253 |
# File 'lib/google/cloud/logging/entry.rb', line 251 def warning! self.severity = :WARNING end |
#warning? ⇒ Boolean
Returns true
if the severity level is :WARNING
.
233 234 235 |
# File 'lib/google/cloud/logging/entry.rb', line 233 def warning? severity == :WARNING end |