google-cloud-logging 2.0.0 → 2.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7260d28a439e63fe96c5fa11487110226714c1f6faf62ed29ffeb48aba5c1914
4
- data.tar.gz: c6eeefa5d3000417ca70eecbcc3a947268776947ad4922e08cb572579ae46257
3
+ metadata.gz: 03bd39c0a616fed279887171144ac18e4e1d77e2e32119ac86a96e7433127699
4
+ data.tar.gz: aa0cefe0ac5f7c5585f41c18d39f03fd50514aba3ff1d2e63762c9789ebbc869
5
5
  SHA512:
6
- metadata.gz: fc5593e6afcb5076293746ed65d754ba32b65df69e6749198eef48e9c23e0277e558fb2abb6064917ee947376d6506349916c9ea003f1bc59bcb89e0e3a71a9e
7
- data.tar.gz: c4cf55027963d1ab020e3cae9049087dbf602860c5eb81c623059d5d6f3c4d0495cd30abda2b621ac385ba77c0c68ace6a9bb5851b90ac57fe57f28ce510a631
6
+ metadata.gz: 8dbe4c7c7df4f0fd9d0b5c4aa2bb8b02eaa17d06182562df30a910982b0550eafa2a8c0740d86b172c27fb8b04ff3aa2b60a9a233aeebe8913c041a2efe02d1e
7
+ data.tar.gz: 9456b8025a5272e5d7ba64e07fe95ad37237d24e68306c5c09806637852f1a4ab9472c2cfe733f6b4e044166d51c3daf13d6407eb80fac02ffd71e59b9ad738b
data/AUTHENTICATION.md CHANGED
@@ -96,7 +96,8 @@ client = Google::Cloud::Logging.new
96
96
 
97
97
  ### Configuration
98
98
 
99
- The **Project ID** and **Credentials JSON** can be configured instead of placing them in environment variables or providing them as arguments.
99
+ The **Project ID** and the path to the **Credentials JSON** file can be configured
100
+ instead of placing them in environment variables or providing them as arguments.
100
101
 
101
102
  ```ruby
102
103
  require "google/cloud/logging"
data/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Release History
2
2
 
3
+ ### 2.2.2 / 2021-10-21
4
+
5
+ #### Documentation
6
+
7
+ * Add documentation for quota_project Configuration attribute
8
+
9
+ ### 2.2.1 / 2021-07-08
10
+
11
+ #### Documentation
12
+
13
+ * Update AUTHENTICATION.md in handwritten packages
14
+
15
+ ### 2.2.0 / 2021-03-10
16
+
17
+ #### Features
18
+
19
+ * Drop support for Ruby 2.4 and add support for Ruby 3.0
20
+
21
+ ### 2.1.0 / 2020-09-16
22
+
23
+ #### Features
24
+
25
+ * quota_project can be set via library configuration
26
+
3
27
  ### 2.0.0 / 2020-07-21
4
28
 
5
29
  This is a major update that removes the "low-level" client interface code, and
data/CONTRIBUTING.md CHANGED
@@ -24,7 +24,7 @@ be able to accept your pull requests.
24
24
  In order to use the google-cloud-logging console and run the project's tests,
25
25
  there is a small amount of setup:
26
26
 
27
- 1. Install Ruby. google-cloud-logging requires Ruby 2.4+. You may choose to
27
+ 1. Install Ruby. google-cloud-logging requires Ruby 2.5+. You may choose to
28
28
  manage your Ruby and gem installations with [RVM](https://rvm.io/),
29
29
  [rbenv](https://github.com/rbenv/rbenv), or
30
30
  [chruby](https://github.com/postmodern/chruby).
@@ -45,7 +45,7 @@ there is a small amount of setup:
45
45
 
46
46
  ```sh
47
47
  $ cd google-cloud-logging/
48
- $ bundle update
48
+ $ bundle install
49
49
  ```
50
50
 
51
51
  ## Console
@@ -119,15 +119,14 @@ If you alter an example's title, you may encounter breaking tests.
119
119
  ### Logging Acceptance Tests
120
120
 
121
121
  The Logging acceptance tests interact with the live service API. Follow the
122
- instructions in the {file:AUTHENTICATION.md Authentication guide} for enabling
122
+ instructions in the {file:AUTHENTICATION.md Authentication Guide} for enabling
123
123
  the Logging API. Occasionally, some API features may not yet be generally
124
124
  available, making it difficult for some contributors to successfully run the
125
125
  entire acceptance test suite. However, please ensure that you do successfully
126
126
  run acceptance tests for any code areas covered by your pull request.
127
127
 
128
128
  To run the acceptance tests, first create and configure a project in the Google
129
- Developers Console, as described in the {file:AUTHENTICATION.md Authentication
130
- guide}. Be sure to download the JSON KEY file. Make note of the PROJECT_ID and
129
+ Developers Console, as described in the {file:AUTHENTICATION.md Authentication Guide}. Be sure to download the JSON KEY file. Make note of the PROJECT_ID and
131
130
  the KEYFILE location on your system.
132
131
 
133
132
  Before you can run the Logging acceptance tests, you must first create indexes
data/LOGGING.md CHANGED
@@ -3,7 +3,7 @@
3
3
  To enable logging for this library, set the logger for the underlying
4
4
  [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library. The logger
5
5
  that you set may be a Ruby stdlib
6
- [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as
6
+ [`Logger`](https://ruby-doc.org/stdlib/libdoc/logger/rdoc/Logger.html) as
7
7
  shown below, or a
8
8
  [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
9
9
  that will write logs to [Stackdriver
data/OVERVIEW.md CHANGED
@@ -317,5 +317,4 @@ logging = Google::Cloud::Logging.new timeout: 120
317
317
  ## Additional information
318
318
 
319
319
  Stackdriver Logging can be configured to be used in Rack applications or to use
320
- gRPC's logging. To learn more, see the {file:INSTRUMENTATION.md Instrumentation
321
- Guide} and {file:LOGGING.md Logging guide}.
320
+ gRPC's logging. To learn more, see the {file:INSTRUMENTATION.md Instrumentation Guide} and {file:LOGGING.md Logging guide}.
@@ -65,7 +65,7 @@ module Google
65
65
 
66
66
  ##
67
67
  # @private Creates a new AsyncWriter instance.
68
- def initialize logging, max_count: 10000, max_bytes: 10000000,
68
+ def initialize logging, max_count: 10_000, max_bytes: 10_000_000,
69
69
  max_queue: 100, interval: 5, threads: 10,
70
70
  partial_success: false
71
71
  # init MonitorMixin
@@ -210,7 +210,7 @@ module Google
210
210
  @stopped = true
211
211
  publish_batch!
212
212
  @cond.broadcast
213
- @thread_pool.shutdown if @thread_pool
213
+ @thread_pool&.shutdown
214
214
  end
215
215
 
216
216
  self
@@ -457,7 +457,8 @@ module Google
457
457
  ##
458
458
  # @private
459
459
  class Batch
460
- attr_reader :created_at, :entries
460
+ attr_reader :created_at
461
+ attr_reader :entries
461
462
 
462
463
  def initialize writer
463
464
  @writer = writer
@@ -499,7 +500,7 @@ module Google
499
500
 
500
501
  def publish_wait
501
502
  publish_wait = publish_at - Time.now
502
- return 0 if publish_wait < 0
503
+ return 0 if publish_wait.negative?
503
504
  publish_wait
504
505
  end
505
506
 
@@ -39,14 +39,19 @@ module Google
39
39
  # @private Convert an Object to a Google::Protobuf::Value.
40
40
  def self.object_to_value obj
41
41
  case obj
42
- when NilClass then Google::Protobuf::Value.new null_value: :NULL_VALUE
43
- when Numeric then Google::Protobuf::Value.new number_value: obj
44
- when String then Google::Protobuf::Value.new string_value: obj
45
- when TrueClass then Google::Protobuf::Value.new bool_value: true
46
- when FalseClass then Google::Protobuf::Value.new bool_value: false
47
- when Hash then
42
+ when NilClass
43
+ Google::Protobuf::Value.new null_value: :NULL_VALUE
44
+ when Numeric
45
+ Google::Protobuf::Value.new number_value: obj
46
+ when String
47
+ Google::Protobuf::Value.new string_value: obj
48
+ when TrueClass
49
+ Google::Protobuf::Value.new bool_value: true
50
+ when FalseClass
51
+ Google::Protobuf::Value.new bool_value: false
52
+ when Hash
48
53
  Google::Protobuf::Value.new struct_value: hash_to_struct(obj)
49
- when Array then
54
+ when Array
50
55
  Google::Protobuf::Value.new list_value: array_to_list(obj)
51
56
  else
52
57
  # TODO: Could raise ArgumentError here, or convert to a string
@@ -27,7 +27,8 @@ module Google
27
27
  class HttpRequest
28
28
  ##
29
29
  # @private Create an empty HttpRequest object.
30
- def initialize; end
30
+ def initialize
31
+ end
31
32
 
32
33
  ##
33
34
  # The request method. Examples: `"GET"`, `"HEAD"`, `"PUT"`, `"POST"`.
@@ -126,17 +126,17 @@ module Google
126
126
  # puts "[#{e.timestamp}] #{e.log_name} #{e.payload.inspect}"
127
127
  # end
128
128
  #
129
- def all request_limit: nil
129
+ def all request_limit: nil, &block
130
130
  request_limit = request_limit.to_i if request_limit
131
131
  unless block_given?
132
132
  return enum_for :all, request_limit: request_limit
133
133
  end
134
134
  results = self
135
135
  loop do
136
- results.each { |r| yield r }
136
+ results.each(&block)
137
137
  if request_limit
138
138
  request_limit -= 1
139
- break if request_limit < 0
139
+ break if request_limit.negative?
140
140
  end
141
141
  break unless results.next?
142
142
  results = results.next
@@ -28,7 +28,8 @@ module Google
28
28
  class Operation
29
29
  ##
30
30
  # @private Create an empty Operation object.
31
- def initialize; end
31
+ def initialize
32
+ end
32
33
 
33
34
  ##
34
35
  # An arbitrary operation identifier. Log entries with the same
@@ -28,7 +28,8 @@ module Google
28
28
  class SourceLocation
29
29
  ##
30
30
  # @private Create an empty SourceLocation object.
31
- def initialize; end
31
+ def initialize
32
+ end
32
33
 
33
34
  ##
34
35
  # Source file name. Depending on the runtime environment, this might
@@ -110,17 +110,17 @@ module Google
110
110
  #
111
111
  # logs.all(request_limit: 10) { |l| puts l }
112
112
  #
113
- def all request_limit: nil
113
+ def all request_limit: nil, &block
114
114
  request_limit = request_limit.to_i if request_limit
115
115
  unless block_given?
116
116
  return enum_for :all, request_limit: request_limit
117
117
  end
118
118
  results = self
119
119
  loop do
120
- results.each { |r| yield r }
120
+ results.each(&block)
121
121
  if request_limit
122
122
  request_limit -= 1
123
- break if request_limit < 0
123
+ break if request_limit.negative?
124
124
  end
125
125
  break unless results.next?
126
126
  results = results.next
@@ -313,14 +313,8 @@ module Google
313
313
  severity = derive_severity(severity) || ::Logger::UNKNOWN
314
314
  return true if severity < @level
315
315
 
316
- if message.nil?
317
- if block_given?
318
- message = yield
319
- else
320
- message = progname
321
- # progname = nil # TODO: Figure out what to do with the progname
322
- end
323
- end
316
+ message ||= block_given? ? yield : progname
317
+ # TODO: Figure out what to do with the progname
324
318
 
325
319
  write_entry severity, message unless @closed
326
320
  true
@@ -570,7 +564,7 @@ module Google
570
564
  end
571
565
  end
572
566
 
573
- request_env = info && info.env || {}
567
+ request_env = info&.env || {}
574
568
 
575
569
  compute_labels(request_env).merge merged_labels
576
570
  end
@@ -594,7 +588,7 @@ module Google
594
588
  ##
595
589
  # @private Get Google Cloud deverity from logger level number.
596
590
  def gcloud_severity severity_int
597
- %i[DEBUG INFO WARNING ERROR CRITICAL DEFAULT][severity_int]
591
+ [:DEBUG, :INFO, :WARNING, :ERROR, :CRITICAL, :DEFAULT][severity_int]
598
592
  rescue StandardError
599
593
  :DEFAULT
600
594
  end
@@ -610,11 +604,9 @@ module Google
610
604
  ##
611
605
  # @private Compute values for labels
612
606
  def compute_labels request_env
613
- Hash[
614
- labels.map do |k, value_or_proc|
615
- [k, compute_label_value(request_env, value_or_proc)]
616
- end
617
- ]
607
+ labels.to_h.transform_values do |value_or_proc|
608
+ compute_label_value request_env, value_or_proc
609
+ end
618
610
  end
619
611
 
620
612
  ##
@@ -123,17 +123,17 @@ module Google
123
123
  # puts "#{metric.name}: #{metric.filter}"
124
124
  # end
125
125
  #
126
- def all request_limit: nil
126
+ def all request_limit: nil, &block
127
127
  request_limit = request_limit.to_i if request_limit
128
128
  unless block_given?
129
129
  return enum_for :all, request_limit: request_limit
130
130
  end
131
131
  results = self
132
132
  loop do
133
- results.each { |r| yield r }
133
+ results.each(&block)
134
134
  if request_limit
135
135
  request_limit -= 1
136
- break if request_limit < 0
136
+ break if request_limit.negative?
137
137
  end
138
138
  break unless results.next?
139
139
  results = results.next
@@ -57,7 +57,7 @@ module Google
57
57
  def initialize app, logger: nil, on_init: nil, **kwargs
58
58
  @app = app
59
59
 
60
- load_config kwargs
60
+ load_config(**kwargs)
61
61
 
62
62
  logger ||= Middleware.logger
63
63
  logger ||= begin
@@ -71,7 +71,7 @@ module Google
71
71
  Middleware.logger = logging.logger log_name, resource
72
72
  end
73
73
 
74
- on_init.call if on_init
74
+ on_init&.call
75
75
 
76
76
  @logger = logger
77
77
  end
@@ -288,9 +288,7 @@ module Google
288
288
  ##
289
289
  # Fallback to default configuration values if not defined already
290
290
  def init_default_config
291
- configuration.project_id ||= begin
292
- (Cloud.configure.project_id || Logging.default_project_id)
293
- end
291
+ configuration.project_id ||= (Cloud.configure.project_id || Logging.default_project_id)
294
292
  configuration.credentials ||= Cloud.configure.credentials
295
293
  configuration.log_name ||= DEFAULT_LOG_NAME
296
294
  configuration.log_name_map ||= DEFAULT_LOG_NAME_MAP
@@ -357,7 +357,7 @@ module Google
357
357
  # resource: resource,
358
358
  # labels: labels
359
359
  #
360
- def async_writer max_batch_count: 10000, max_batch_bytes: 10000000,
360
+ def async_writer max_batch_count: 10_000, max_batch_bytes: 10_000_000,
361
361
  max_queue_size: 100, interval: 5, threads: 10,
362
362
  partial_success: false
363
363
 
@@ -158,7 +158,7 @@ module Google
158
158
  ##
159
159
  # @private Merge Rails configuration into Logging instrumentation
160
160
  # configuration.
161
- def self.merge_rails_config rails_config # rubocop:disable AbcSize
161
+ def self.merge_rails_config rails_config
162
162
  gcp_config = rails_config.google_cloud
163
163
  log_config = gcp_config.logging
164
164
 
@@ -175,13 +175,10 @@ module Google
175
175
  config.log_name ||= log_config.log_name
176
176
  config.labels ||= log_config.labels
177
177
  config.log_name_map ||= log_config.log_name_map
178
- config.monitored_resource.type ||=
179
- log_config.monitored_resource.type
180
- config.monitored_resource.labels ||=
181
- log_config.monitored_resource.labels.to_h
178
+ config.monitored_resource.type ||= log_config.monitored_resource.type
179
+ config.monitored_resource.labels ||= log_config.monitored_resource.labels.to_h
182
180
  if config.set_default_logger_on_rails_init.nil?
183
- config.set_default_logger_on_rails_init = \
184
- log_config.set_default_logger_on_rails_init
181
+ config.set_default_logger_on_rails_init = log_config.set_default_logger_on_rails_init
185
182
  end
186
183
  end
187
184
  end
@@ -206,15 +203,15 @@ module Google
206
203
  # if credentials is not a Credentials object, create one
207
204
  Logging::Credentials.new credentials
208
205
  end
209
- rescue Exception => e
210
- STDOUT.puts "Note: Google::Cloud::Logging is disabled because " \
206
+ rescue Exception => e # rubocop:disable Lint/RescueException
207
+ $stdout.puts "Note: Google::Cloud::Logging is disabled because " \
211
208
  "it failed to authorize with the service. (#{e.message}) " \
212
209
  "Falling back to the default Rails logger."
213
210
  return false
214
211
  end
215
212
 
216
213
  if project_id.to_s.empty?
217
- STDOUT.puts "Note: Google::Cloud::Logging is disabled because " \
214
+ $stdout.puts "Note: Google::Cloud::Logging is disabled because " \
218
215
  "the project ID could not be determined. " \
219
216
  "Falling back to the default Rails logger."
220
217
  return false
@@ -128,17 +128,17 @@ module Google
128
128
  # puts rd.type
129
129
  # end
130
130
  #
131
- def all request_limit: nil
131
+ def all request_limit: nil, &block
132
132
  request_limit = request_limit.to_i if request_limit
133
133
  unless block_given?
134
134
  return enum_for :all, request_limit: request_limit
135
135
  end
136
136
  results = self
137
137
  loop do
138
- results.each { |r| yield r }
138
+ results.each(&block)
139
139
  if request_limit
140
140
  request_limit -= 1
141
- break if request_limit < 0
141
+ break if request_limit.negative?
142
142
  end
143
143
  break unless results.next?
144
144
  results = results.next
@@ -25,7 +25,10 @@ module Google
25
25
  # @private Represents the gRPC Logging service, including all the API
26
26
  # methods.
27
27
  class Service
28
- attr_accessor :project, :credentials, :timeout, :host
28
+ attr_accessor :project
29
+ attr_accessor :credentials
30
+ attr_accessor :timeout
31
+ attr_accessor :host
29
32
 
30
33
  ##
31
34
  # Creates a new Service instance.
@@ -122,17 +122,17 @@ module Google
122
122
  # puts "#{sink.name}: #{sink.filter} -> #{sink.destination}"
123
123
  # end
124
124
  #
125
- def all request_limit: nil
125
+ def all request_limit: nil, &block
126
126
  request_limit = request_limit.to_i if request_limit
127
127
  unless block_given?
128
128
  return enum_for :all, request_limit: request_limit
129
129
  end
130
130
  results = self
131
131
  loop do
132
- results.each { |r| yield r }
132
+ results.each(&block)
133
133
  if request_limit
134
134
  request_limit -= 1
135
- break if request_limit < 0
135
+ break if request_limit.negative?
136
136
  end
137
137
  break unless results.next?
138
138
  results = results.next
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Logging
19
- VERSION = "2.0.0".freeze
19
+ VERSION = "2.2.2".freeze
20
20
  end
21
21
  end
22
22
  end
@@ -124,6 +124,8 @@ module Google
124
124
  # parameter `keyfile` is considered deprecated, but may also be used.)
125
125
  # * `scope` - (String, Array<String>) The OAuth 2.0 scopes controlling
126
126
  # the set of resources and operations that the connection can access.
127
+ # * `quota_project` - (String) The project ID for a project that can be
128
+ # used by client libraries for quota and billing purposes.
127
129
  # * `timeout` - (Integer) Default timeout to use in requests.
128
130
  # * `endpoint` - (String) Override of the endpoint host name, or `nil`
129
131
  # to use the default endpoint.
@@ -147,6 +147,7 @@ Google::Cloud.configure.add_config! :logging do |config|
147
147
  allow_nil: true
148
148
  config.add_alias! :keyfile, :credentials
149
149
  config.add_field! :scope, default_scopes, match: [String, Array]
150
+ config.add_field! :quota_project, nil, match: String
150
151
  config.add_field! :timeout, nil, match: Integer
151
152
  config.add_field! :endpoint, "logging.googleapis.com", match: String
152
153
  config.add_field! :log_name, nil, match: String
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Moore
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-07-21 00:00:00.000000000 Z
12
+ date: 2021-10-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core
@@ -73,14 +73,14 @@ dependencies:
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: 1.24.0
76
+ version: 1.25.1
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: 1.24.0
83
+ version: 1.25.1
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: minitest
86
86
  requirement: !ruby/object:Gem::Requirement
@@ -290,14 +290,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
290
290
  requirements:
291
291
  - - ">="
292
292
  - !ruby/object:Gem::Version
293
- version: '2.4'
293
+ version: '2.5'
294
294
  required_rubygems_version: !ruby/object:Gem::Requirement
295
295
  requirements:
296
296
  - - ">="
297
297
  - !ruby/object:Gem::Version
298
298
  version: '0'
299
299
  requirements: []
300
- rubygems_version: 3.1.3
300
+ rubygems_version: 3.2.17
301
301
  signing_key:
302
302
  specification_version: 4
303
303
  summary: API Client library for Stackdriver Logging