google-cloud-logging 1.2.3 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/google-cloud-logging.rb +13 -10
- data/lib/google/cloud/logging.rb +41 -17
- data/lib/google/cloud/logging/async_writer.rb +5 -2
- data/lib/google/cloud/logging/credentials.rb +31 -15
- data/lib/google/cloud/logging/entry.rb +13 -0
- data/lib/google/cloud/logging/entry/http_request.rb +35 -12
- data/lib/google/cloud/logging/logger.rb +14 -0
- data/lib/google/cloud/logging/middleware.rb +1 -1
- data/lib/google/cloud/logging/project.rb +55 -8
- data/lib/google/cloud/logging/rails.rb +1 -1
- data/lib/google/cloud/logging/service.rb +8 -27
- data/lib/google/cloud/logging/v2/config_service_v2_client.rb +360 -93
- data/lib/google/cloud/logging/v2/config_service_v2_client_config.json +43 -8
- data/lib/google/cloud/logging/v2/doc/google/api/distribution.rb +172 -0
- data/lib/google/cloud/logging/v2/doc/google/api/metric.rb +187 -0
- data/lib/google/cloud/logging/v2/doc/google/api/monitored_resource.rb +4 -4
- data/lib/google/cloud/logging/v2/doc/google/logging/type/http_request.rb +4 -1
- data/lib/google/cloud/logging/v2/doc/google/logging/v2/log_entry.rb +13 -6
- data/lib/google/cloud/logging/v2/doc/google/logging/v2/logging.rb +55 -21
- data/lib/google/cloud/logging/v2/doc/google/logging/v2/logging_config.rb +185 -23
- data/lib/google/cloud/logging/v2/doc/google/logging/v2/logging_metrics.rb +89 -5
- data/lib/google/cloud/logging/v2/doc/google/protobuf/any.rb +12 -2
- data/lib/google/cloud/logging/v2/doc/google/protobuf/duration.rb +14 -1
- data/lib/google/cloud/logging/v2/doc/google/protobuf/field_mask.rb +223 -0
- data/lib/google/cloud/logging/v2/doc/google/protobuf/timestamp.rb +26 -1
- data/lib/google/cloud/logging/v2/doc/overview.rb +67 -0
- data/lib/google/cloud/logging/v2/logging_service_v2_client.rb +116 -91
- data/lib/google/cloud/logging/v2/logging_service_v2_client_config.json +12 -11
- data/lib/google/cloud/logging/v2/metrics_service_v2_client.rb +87 -76
- data/lib/google/cloud/logging/v2/metrics_service_v2_client_config.json +9 -8
- data/lib/google/cloud/logging/version.rb +1 -1
- metadata +11 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 64d96c3d7c2e3e65da43168f7769ab9d4cf8a56f789d7cdc6c53e09bc62ae262
|
4
|
+
data.tar.gz: 9d49322540e7bbdcc2cb80f4277c8aa190c6ad4321ddcbf4365b2b9239e5a242
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 272469c7d46c8afce6bfb28c84174bea9ab2a0ea8fe8d7200a9ce8dd37c2c3f83825c42897bcae8e967b679f7ff3c9ed88d46bfad1510e725873f4139cf77889
|
7
|
+
data.tar.gz: 2631db81f9ccec5255b67f9d52e69be34493703df39bd7a575c8d6f8e45808d2de7d5fa0d1d3155b2b42ee3a46c8f60f97779e270a0c8e98fbc9682e51bc2ebd
|
data/lib/google-cloud-logging.rb
CHANGED
@@ -13,9 +13,9 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
##
|
16
|
-
# This file is here to be autorequired by bundler, so that the
|
17
|
-
# #logging methods can be available, but
|
18
|
-
# be loaded until required and used.
|
16
|
+
# This file is here to be autorequired by bundler, so that the
|
17
|
+
# Google::Cloud.logging and Google::Cloud#logging methods can be available, but
|
18
|
+
# the library and all dependencies won't be loaded until required and used.
|
19
19
|
|
20
20
|
|
21
21
|
gem "google-cloud-core"
|
@@ -75,10 +75,12 @@ module Google
|
|
75
75
|
# For more information on connecting to Google Cloud see the [Authentication
|
76
76
|
# Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/guides/authentication).
|
77
77
|
#
|
78
|
-
# @param [String]
|
79
|
-
# service you are connecting to.
|
80
|
-
#
|
81
|
-
#
|
78
|
+
# @param [String] project_id Project identifier for the Stackdriver Logging
|
79
|
+
# service you are connecting to. If not present, the default project for
|
80
|
+
# the credentials is used.
|
81
|
+
# @param [String, Hash, Google::Auth::Credentials] credentials The path to
|
82
|
+
# the keyfile as a String, the contents of the keyfile as a Hash, or a
|
83
|
+
# Google::Auth::Credentials object. (See {Logging::Credentials})
|
82
84
|
# @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the
|
83
85
|
# set of resources and operations that the connection can access. See
|
84
86
|
# [Using OAuth 2.0 to Access Google
|
@@ -103,10 +105,11 @@ module Google
|
|
103
105
|
# puts "[#{e.timestamp}] #{e.log_name} #{e.payload.inspect}"
|
104
106
|
# end
|
105
107
|
#
|
106
|
-
def self.logging
|
107
|
-
client_config: nil
|
108
|
+
def self.logging project_id = nil, credentials = nil, scope: nil,
|
109
|
+
timeout: nil, client_config: nil
|
108
110
|
require "google/cloud/logging"
|
109
|
-
Google::Cloud::Logging.new
|
111
|
+
Google::Cloud::Logging.new project_id: project_id,
|
112
|
+
credentials: credentials,
|
110
113
|
scope: scope, timeout: timeout,
|
111
114
|
client_config: client_config
|
112
115
|
end
|
data/lib/google/cloud/logging.rb
CHANGED
@@ -222,6 +222,23 @@ module Google
|
|
222
222
|
# logging.write_entries entry
|
223
223
|
# ```
|
224
224
|
#
|
225
|
+
# To write a JSON payload to the log, simply pass a hash argument:
|
226
|
+
#
|
227
|
+
# ```ruby
|
228
|
+
# require "google/cloud/logging"
|
229
|
+
#
|
230
|
+
# logging = Google::Cloud::Logging.new
|
231
|
+
#
|
232
|
+
# entry = logging.entry
|
233
|
+
# entry.payload = { "stats" => { "a" => 8, "b" => 12.5} }
|
234
|
+
# entry.log_name = "my_app_log"
|
235
|
+
# entry.resource.type = "gae_app"
|
236
|
+
# entry.resource.labels[:module_id] = "1"
|
237
|
+
# entry.resource.labels[:version_id] = "20150925t173233"
|
238
|
+
#
|
239
|
+
# logging.write_entries entry
|
240
|
+
# ```
|
241
|
+
#
|
225
242
|
# If you write a collection of log entries, you can provide the log name,
|
226
243
|
# resource, and/or labels hash to be used for all of the entries, and omit
|
227
244
|
# these values from the individual entries.
|
@@ -274,7 +291,8 @@ module Google
|
|
274
291
|
# async.write_entries [entry1, entry2],
|
275
292
|
# log_name: "my_app_log",
|
276
293
|
# resource: resource,
|
277
|
-
# labels: labels
|
294
|
+
# labels: labels,
|
295
|
+
# partial_success: true
|
278
296
|
# ```
|
279
297
|
#
|
280
298
|
# ### Creating a Ruby Logger implementation
|
@@ -343,10 +361,12 @@ module Google
|
|
343
361
|
# [Authentication
|
344
362
|
# Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/guides/authentication).
|
345
363
|
#
|
346
|
-
# @param [String]
|
347
|
-
# service.
|
348
|
-
#
|
349
|
-
#
|
364
|
+
# @param [String] project_id Project identifier for the Stackdriver
|
365
|
+
# Logging service you are connecting to. If not present, the default
|
366
|
+
# project for the credentials is used.
|
367
|
+
# @param [String, Hash, Google::Auth::Credentials] credentials The path to
|
368
|
+
# the keyfile as a String, the contents of the keyfile as a Hash, or a
|
369
|
+
# Google::Auth::Credentials object. (See {Logging::Credentials})
|
350
370
|
# @param [String, Array<String>] scope The OAuth 2.0 scopes controlling
|
351
371
|
# the set of resources and operations that the connection can access.
|
352
372
|
# See [Using OAuth 2.0 to Access Google
|
@@ -358,6 +378,9 @@ module Google
|
|
358
378
|
# @param [Integer] timeout Default timeout to use in requests. Optional.
|
359
379
|
# @param [Hash] client_config A hash of values to override the default
|
360
380
|
# behavior of the API client. Optional.
|
381
|
+
# @param [String] project Alias for the `project_id` argument. Deprecated.
|
382
|
+
# @param [String] keyfile Alias for the `credentials` argument.
|
383
|
+
# Deprecated.
|
361
384
|
#
|
362
385
|
# @return [Google::Cloud::Logging::Project]
|
363
386
|
#
|
@@ -371,20 +394,21 @@ module Google
|
|
371
394
|
# puts "[#{e.timestamp}] #{e.log_name} #{e.payload.inspect}"
|
372
395
|
# end
|
373
396
|
#
|
374
|
-
def self.new
|
375
|
-
client_config: nil
|
376
|
-
|
377
|
-
|
378
|
-
fail ArgumentError, "
|
397
|
+
def self.new project_id: nil, credentials: nil, scope: nil, timeout: nil,
|
398
|
+
client_config: nil, project: nil, keyfile: nil
|
399
|
+
project_id ||= (project || Logging::Project.default_project_id)
|
400
|
+
project_id = project_id.to_s # Always cast to a string
|
401
|
+
fail ArgumentError, "project_id is missing" if project_id.empty?
|
379
402
|
|
380
|
-
credentials
|
381
|
-
|
382
|
-
|
403
|
+
credentials ||= (keyfile || Logging::Credentials.default(scope: scope))
|
404
|
+
unless credentials.is_a? Google::Auth::Credentials
|
405
|
+
credentials = Logging::Credentials.new credentials, scope: scope
|
406
|
+
end
|
383
407
|
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
408
|
+
Logging::Project.new(
|
409
|
+
Logging::Service.new(
|
410
|
+
project_id, credentials, timeout: timeout,
|
411
|
+
client_config: client_config))
|
388
412
|
end
|
389
413
|
|
390
414
|
##
|
@@ -96,11 +96,13 @@ module Google
|
|
96
96
|
|
97
97
|
##
|
98
98
|
# @private Creates a new AsyncWriter instance.
|
99
|
-
def initialize logging, max_queue_size = DEFAULT_MAX_QUEUE_SIZE
|
99
|
+
def initialize logging, max_queue_size = DEFAULT_MAX_QUEUE_SIZE,
|
100
|
+
partial_success = false
|
100
101
|
super()
|
101
102
|
|
102
103
|
@logging = logging
|
103
104
|
@max_queue_size = max_queue_size
|
105
|
+
@partial_success = partial_success
|
104
106
|
@queue_resource = new_cond
|
105
107
|
@queue = []
|
106
108
|
@queue_size = 0
|
@@ -335,7 +337,8 @@ module Google
|
|
335
337
|
queue_item.entries,
|
336
338
|
log_name: queue_item.log_name,
|
337
339
|
resource: queue_item.resource,
|
338
|
-
labels: queue_item.labels
|
340
|
+
labels: queue_item.labels,
|
341
|
+
partial_success: @partial_success
|
339
342
|
)
|
340
343
|
rescue => e
|
341
344
|
# Ignore any exceptions thrown from the background thread, but
|
@@ -13,28 +13,44 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
|
16
|
-
require "
|
16
|
+
require "googleauth"
|
17
17
|
|
18
18
|
module Google
|
19
19
|
module Cloud
|
20
20
|
module Logging
|
21
21
|
##
|
22
|
-
#
|
23
|
-
|
22
|
+
# # Credentials
|
23
|
+
#
|
24
|
+
# Represents the authentication and authorization used to connect to the
|
25
|
+
# Stackdriver Logging API.
|
26
|
+
#
|
27
|
+
# @example
|
28
|
+
# require "google/cloud/logging"
|
29
|
+
#
|
30
|
+
# keyfile = "/path/to/keyfile.json"
|
31
|
+
# creds = Google::Cloud::Logging::Credentials.new keyfile
|
32
|
+
#
|
33
|
+
# logging = Google::Cloud::Logging.new(
|
34
|
+
# project_id: "my-project",
|
35
|
+
# credentials: creds
|
36
|
+
# )
|
37
|
+
#
|
38
|
+
# logging.project_id #=> "my-project"
|
39
|
+
#
|
40
|
+
class Credentials < Google::Auth::Credentials
|
24
41
|
SCOPE = ["https://www.googleapis.com/auth/logging.admin"]
|
25
|
-
PATH_ENV_VARS = %w(
|
26
|
-
|
42
|
+
PATH_ENV_VARS = %w(LOGGING_CREDENTIALS
|
43
|
+
LOGGING_KEYFILE
|
44
|
+
GOOGLE_CLOUD_CREDENTIALS
|
45
|
+
GOOGLE_CLOUD_KEYFILE
|
46
|
+
GCLOUD_KEYFILE)
|
47
|
+
JSON_ENV_VARS = %w(LOGGING_CREDENTIALS_JSON
|
48
|
+
LOGGING_KEYFILE_JSON
|
49
|
+
GOOGLE_CLOUD_CREDENTIALS_JSON
|
50
|
+
GOOGLE_CLOUD_KEYFILE_JSON
|
27
51
|
GCLOUD_KEYFILE_JSON)
|
28
|
-
|
29
|
-
|
30
|
-
# @private Create credentials with given scope and/or keyfile
|
31
|
-
def self.credentials_with_scope keyfile, scope = nil
|
32
|
-
if keyfile.nil?
|
33
|
-
default(scope: scope)
|
34
|
-
else
|
35
|
-
new(keyfile, scope: scope)
|
36
|
-
end
|
37
|
-
end
|
52
|
+
DEFAULT_PATHS = \
|
53
|
+
["~/.config/gcloud/application_default_credentials.json"]
|
38
54
|
end
|
39
55
|
end
|
40
56
|
end
|
@@ -57,6 +57,19 @@ module Google
|
|
57
57
|
#
|
58
58
|
# logging.write_entries entry
|
59
59
|
#
|
60
|
+
# @example Provide a hash to write a JSON payload to the log:
|
61
|
+
# require "google/cloud/logging"
|
62
|
+
#
|
63
|
+
# logging = Google::Cloud::Logging.new
|
64
|
+
#
|
65
|
+
# payload = { "stats" => { "a" => 8, "b" => 12.5} }
|
66
|
+
# entry = logging.entry payload: payload, log_name: "my_app_log"
|
67
|
+
# entry.resource.type = "gae_app"
|
68
|
+
# entry.resource.labels[:module_id] = "1"
|
69
|
+
# entry.resource.labels[:version_id] = "20150925t173233"
|
70
|
+
#
|
71
|
+
# logging.write_entries entry
|
72
|
+
#
|
60
73
|
class Entry
|
61
74
|
##
|
62
75
|
# Create a new Entry instance. The {#resource} attribute is
|
@@ -33,7 +33,30 @@ module Google
|
|
33
33
|
##
|
34
34
|
# The request method. Examples: `"GET"`, `"HEAD"`, `"PUT"`, `"POST"`.
|
35
35
|
# (String)
|
36
|
-
attr_accessor :
|
36
|
+
attr_accessor :request_method
|
37
|
+
|
38
|
+
##
|
39
|
+
# @overload method()
|
40
|
+
# Deprecated. Use {#request_method} instead.
|
41
|
+
#
|
42
|
+
# The request method. Examples: `"GET"`, `"HEAD"`, `"PUT"`,
|
43
|
+
# `"POST"`. (String)
|
44
|
+
def method *args
|
45
|
+
# Call Object#method when args are present.
|
46
|
+
return super unless args.empty?
|
47
|
+
|
48
|
+
request_method
|
49
|
+
end
|
50
|
+
|
51
|
+
##
|
52
|
+
# @overload method()
|
53
|
+
# Deprecated. Use {#request_method=} instead.
|
54
|
+
#
|
55
|
+
# The request method. Examples: `"GET"`, `"HEAD"`, `"PUT"`,
|
56
|
+
# `"POST"`. (String)
|
57
|
+
def method= new_request_method
|
58
|
+
self.request_method = new_request_method
|
59
|
+
end
|
37
60
|
|
38
61
|
##
|
39
62
|
# The URL. The scheme (http, https), the host name, the path and the
|
@@ -107,7 +130,7 @@ module Google
|
|
107
130
|
def to_grpc
|
108
131
|
return nil if empty?
|
109
132
|
Google::Logging::Type::HttpRequest.new(
|
110
|
-
request_method:
|
133
|
+
request_method: request_method.to_s,
|
111
134
|
request_url: url.to_s,
|
112
135
|
request_size: size.to_i,
|
113
136
|
status: status.to_i,
|
@@ -126,16 +149,16 @@ module Google
|
|
126
149
|
def self.from_grpc grpc
|
127
150
|
return new if grpc.nil?
|
128
151
|
new.tap do |h|
|
129
|
-
h.
|
130
|
-
h.url
|
131
|
-
h.size
|
132
|
-
h.status
|
133
|
-
h.response_size
|
134
|
-
h.user_agent
|
135
|
-
h.remote_ip
|
136
|
-
h.referer
|
137
|
-
h.cache_hit
|
138
|
-
h.validated
|
152
|
+
h.request_method = grpc.request_method
|
153
|
+
h.url = grpc.request_url
|
154
|
+
h.size = grpc.request_size
|
155
|
+
h.status = grpc.status
|
156
|
+
h.response_size = grpc.response_size
|
157
|
+
h.user_agent = grpc.user_agent
|
158
|
+
h.remote_ip = grpc.remote_ip
|
159
|
+
h.referer = grpc.referer
|
160
|
+
h.cache_hit = grpc.cache_hit
|
161
|
+
h.validated = grpc.cache_validated_with_origin_server
|
139
162
|
end
|
140
163
|
end
|
141
164
|
end
|
@@ -36,6 +36,20 @@ module Google
|
|
36
36
|
# logger = logging.logger "my_app_log", resource, env: :production
|
37
37
|
# logger.info "Job started."
|
38
38
|
#
|
39
|
+
# @example Provide a hash to write a JSON payload to the log:
|
40
|
+
# require "google/cloud/logging"
|
41
|
+
#
|
42
|
+
# logging = Google::Cloud::Logging.new
|
43
|
+
#
|
44
|
+
# resource = logging.resource "gae_app",
|
45
|
+
# module_id: "1",
|
46
|
+
# version_id: "20150925t173233"
|
47
|
+
#
|
48
|
+
# logger = logging.logger "my_app_log", resource, env: :production
|
49
|
+
#
|
50
|
+
# payload = { "stats" => { "a" => 8, "b" => 12.5} }
|
51
|
+
# logger.info payload
|
52
|
+
#
|
39
53
|
class Logger
|
40
54
|
##
|
41
55
|
# A RequestInfo represents data about the request being handled by the
|
@@ -270,7 +270,7 @@ module Google
|
|
270
270
|
# Fallback to default configuration values if not defined already
|
271
271
|
def init_default_config
|
272
272
|
configuration.project_id ||= Cloud.configure.project_id ||
|
273
|
-
Logging::Project.
|
273
|
+
Logging::Project.default_project_id
|
274
274
|
configuration.keyfile ||= Cloud.configure.keyfile
|
275
275
|
configuration.log_name ||= DEFAULT_LOG_NAME
|
276
276
|
configuration.log_name_map ||= DEFAULT_LOG_NAME_MAP
|
@@ -66,19 +66,20 @@ module Google
|
|
66
66
|
# require "google/cloud/logging"
|
67
67
|
#
|
68
68
|
# logging = Google::Cloud::Logging.new(
|
69
|
-
#
|
70
|
-
#
|
69
|
+
# project_id: "my-project",
|
70
|
+
# credentials: "/path/to/keyfile.json"
|
71
71
|
# )
|
72
72
|
#
|
73
|
-
# logging.
|
73
|
+
# logging.project_id #=> "my-project"
|
74
74
|
#
|
75
|
-
def
|
75
|
+
def project_id
|
76
76
|
service.project
|
77
77
|
end
|
78
|
+
alias_method :project, :project_id
|
78
79
|
|
79
80
|
##
|
80
81
|
# @private Default project.
|
81
|
-
def self.
|
82
|
+
def self.default_project_id
|
82
83
|
ENV["LOGGING_PROJECT"] ||
|
83
84
|
ENV["GOOGLE_CLOUD_PROJECT"] ||
|
84
85
|
ENV["GCLOUD_PROJECT"] ||
|
@@ -203,6 +204,16 @@ module Google
|
|
203
204
|
#
|
204
205
|
# logging.write_entries entry
|
205
206
|
#
|
207
|
+
# @example Provide a hash to write a JSON payload to the log:
|
208
|
+
# require "google/cloud/logging"
|
209
|
+
#
|
210
|
+
# logging = Google::Cloud::Logging.new
|
211
|
+
#
|
212
|
+
# payload = { "stats" => { "a" => 8, "b" => 12.5} }
|
213
|
+
# entry = logging.entry severity: :INFO, payload: payload
|
214
|
+
#
|
215
|
+
# logging.write_entries entry
|
216
|
+
#
|
206
217
|
def entry log_name: nil, resource: nil, timestamp: nil, severity: nil,
|
207
218
|
insert_id: nil, labels: nil, payload: nil
|
208
219
|
e = Entry.new
|
@@ -238,6 +249,10 @@ module Google
|
|
238
249
|
# items that are added to the `labels` field of each log entry in
|
239
250
|
# `entries`, except when a log entry specifies its own `key:value`
|
240
251
|
# item with the same key. See also {Entry#labels=}.
|
252
|
+
# @param [Boolean] partial_success Whether valid entries should be
|
253
|
+
# written even if some other entries fail due to INVALID_ARGUMENT or
|
254
|
+
# PERMISSION_DENIED errors when communicating to the Stackdriver
|
255
|
+
# Logging API.
|
241
256
|
#
|
242
257
|
# @return [Boolean] Returns `true` if the entries were written.
|
243
258
|
#
|
@@ -254,6 +269,22 @@ module Google
|
|
254
269
|
#
|
255
270
|
# logging.write_entries entry
|
256
271
|
#
|
272
|
+
# @example Provide a hash to write a JSON payload to the log:
|
273
|
+
# require "google/cloud/logging"
|
274
|
+
#
|
275
|
+
# logging = Google::Cloud::Logging.new
|
276
|
+
#
|
277
|
+
# payload = { "stats" => { "a" => 8, "b" => 12.5} }
|
278
|
+
#
|
279
|
+
# entry = logging.entry payload: payload,
|
280
|
+
# log_name: "my_app_log"
|
281
|
+
# entry.resource.type = "gae_app"
|
282
|
+
# entry.resource.labels[:module_id] = "1"
|
283
|
+
# entry.resource.labels[:version_id] = "20150925t173233"
|
284
|
+
#
|
285
|
+
# logging.write_entries entry
|
286
|
+
#
|
287
|
+
#
|
257
288
|
# @example Optionally pass log name, resource, and labels for entries.
|
258
289
|
# require "google/cloud/logging"
|
259
290
|
#
|
@@ -270,13 +301,15 @@ module Google
|
|
270
301
|
# logging.write_entries [entry1, entry2],
|
271
302
|
# log_name: "my_app_log",
|
272
303
|
# resource: resource,
|
273
|
-
# labels: labels
|
304
|
+
# labels: labels,
|
305
|
+
# partial_success: true
|
274
306
|
#
|
275
|
-
def write_entries entries, log_name: nil, resource: nil, labels: nil
|
307
|
+
def write_entries entries, log_name: nil, resource: nil, labels: nil,
|
308
|
+
partial_success: nil
|
276
309
|
ensure_service!
|
277
310
|
service.write_entries Array(entries).map(&:to_grpc),
|
278
311
|
log_name: log_name, resource: resource,
|
279
|
-
labels: labels
|
312
|
+
labels: labels, partial_success: partial_success
|
280
313
|
true
|
281
314
|
end
|
282
315
|
|
@@ -380,6 +413,20 @@ module Google
|
|
380
413
|
# logger = logging.logger "my_app_log", resource, env: :production
|
381
414
|
# logger.info "Job started."
|
382
415
|
#
|
416
|
+
# @example Provide a hash to write a JSON payload to the log:
|
417
|
+
# require "google/cloud/logging"
|
418
|
+
#
|
419
|
+
# logging = Google::Cloud::Logging.new
|
420
|
+
#
|
421
|
+
# resource = logging.resource "gae_app",
|
422
|
+
# module_id: "1",
|
423
|
+
# version_id: "20150925t173233"
|
424
|
+
#
|
425
|
+
# logger = logging.logger "my_app_log", resource, env: :production
|
426
|
+
#
|
427
|
+
# payload = { "stats" => { "a" => 8, "b" => 12.5} }
|
428
|
+
# logger.info payload
|
429
|
+
#
|
383
430
|
def logger log_name, resource, labels = {}
|
384
431
|
Logger.new shared_async_writer, log_name, resource, labels
|
385
432
|
end
|