google-cloud-logging 2.1.0 → 2.2.0

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: c4373e8c818d66a86866dda2f4655158c801bbc53a715cd403b322a02b06b13c
4
- data.tar.gz: 9a7c2dc232eab76f78d1932c71c8d655bae696de2c2561c07594ceeaafc39215
3
+ metadata.gz: 1bebb4573f1d510e3c8c6d007a92edbafcdf06c1c1a545791429541e7ee1c3db
4
+ data.tar.gz: 69f4fff5db4ac937df49ee56b7b93fbcf55e4041610f84f318f56e70703fca6d
5
5
  SHA512:
6
- metadata.gz: 850c12ebfc25860f521c990d9bc0bf7eedaacd3d7754fa3f2cffcbf14d54107fbd520bdb75c54cba20d347be8f0a1d0e1eb6a2459f765d6dedf01a5c9d5ad295
7
- data.tar.gz: 0e4540e7e5ee45505ebd4384503d88317284d38462176ac018b5c69000de78c913ce4db49abdf79bca3ec59e528ba8d8f0b586c6049d8dbd7d663b93b182a196
6
+ metadata.gz: 7a37da884d7f7f6bd6f7f908f907feda49b59894d7f1534d7b474c77e39e371ea96894185e9921e0a07166f70e2980fb0fc33852679c2dcf440d33cfa8bffdf0
7
+ data.tar.gz: c01f22ade5fd8c14957446b4e372f6e9476cb77c17b54a91079b86556156a5a6201e4cac80a5459fcaf34d791f623fb45396bd6cd643a57d29065d01cbea44a5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Release History
2
2
 
3
+ ### 2.2.0 / 2021-03-10
4
+
5
+ #### Features
6
+
7
+ * Drop support for Ruby 2.4 and add support for Ruby 3.0
8
+
3
9
  ### 2.1.0 / 2020-09-16
4
10
 
5
11
  #### Features
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
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
@@ -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
@@ -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.1.0".freeze
19
+ VERSION = "2.2.0".freeze
20
20
  end
21
21
  end
22
22
  end
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.1.0
4
+ version: 2.2.0
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-09-16 00:00:00.000000000 Z
12
+ date: 2021-03-10 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.4
300
+ rubygems_version: 3.2.13
301
301
  signing_key:
302
302
  specification_version: 4
303
303
  summary: API Client library for Stackdriver Logging