google-cloud-logging 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f630302c8714555f32d66a9a19a5da340c6bbd840b1a1ed9c7da1798b42254df
4
- data.tar.gz: d0fb2056868a23c282082339be24ddd1aeca4c4ff9cc4659b1fd3091b5364596
3
+ metadata.gz: 3ab79fe662f67035257cff75fec93833d4bfce8db1c3621683e3bb9982a7791e
4
+ data.tar.gz: 469eb5b80af7c0314197626009b649d658e6104493c5ccf6cc75e9694904cde6
5
5
  SHA512:
6
- metadata.gz: 484774d516102279b6197436dc1daee472eabd055d24f0d9e4a7460144aec2255cce2ad33bfa176b76713f5e252e72aa05014da53952587c15de9fc7e01688c0
7
- data.tar.gz: 051e5a2e070aa2a2fbef148971fbf1d5e02d05c211720442682775591254803548a31745b359aee8a48be2eb4bd5a2d86671b6dc9ed150070fa550958e7181f3
6
+ metadata.gz: 38683f930c15541f2adaaec7804f5b22c945ac7e768f1511f20abf6d7c8bf587bbc8eaf16e35626bfccc7201f9daf87a582f4c04c4f4e072180cf5596af4fa44
7
+ data.tar.gz: 34dd2648e895ccc122b8de4be189f51f50f70ae38b8a72adced50f5900a0d29c5efa11566a8066656bea49354303937dbd1d3441a613981c50c6c2e56d06e07e
data/README.md CHANGED
@@ -156,10 +156,39 @@ See the [Authentication
156
156
  Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/guides/authentication).
157
157
  for more ways to authenticate the client library.
158
158
 
159
+ ## Enabling Logging
160
+
161
+ To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library. The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below, or a [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger) that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb) and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
162
+
163
+ Configuring a Ruby stdlib logger:
164
+
165
+ ```ruby
166
+ require "logger"
167
+
168
+ module MyLogger
169
+ LOGGER = Logger.new $stderr, level: Logger::WARN
170
+ def logger
171
+ LOGGER
172
+ end
173
+ end
174
+
175
+ # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
176
+ module GRPC
177
+ extend MyLogger
178
+ end
179
+ ```
180
+
159
181
  ## Supported Ruby Versions
160
182
 
161
183
  This library is supported on Ruby 2.0+.
162
184
 
185
+ However, Ruby 2.3 or later is strongly recommended, as earlier releases have
186
+ reached or are nearing end-of-life. After June 1, 2018, Google will provide
187
+ official support only for Ruby versions that are considered current and
188
+ supported by Ruby Core (that is, Ruby versions that are either in normal
189
+ maintenance or in security maintenance).
190
+ See https://www.ruby-lang.org/en/downloads/branches/ for further details.
191
+
163
192
  ## Versioning
164
193
 
165
194
  This library follows [Semantic Versioning](http://semver.org/).
@@ -55,6 +55,39 @@ module Google
55
55
  # implementation](#creating-a-ruby-logger-implementation) provided by this
56
56
  # library. Otherwise, read on to learn more about the Logging API.
57
57
  #
58
+ # ## Enabling Logging
59
+ #
60
+ # To enable logging for this library, set the logger for the underlying
61
+ # [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library. The
62
+ # logger that you set may be a Ruby stdlib
63
+ # [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html)
64
+ # as shown below, or a
65
+ # [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
66
+ # that will write logs to [Stackdriver
67
+ # Logging](https://cloud.google.com/logging/). See
68
+ # [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
69
+ # and the gRPC
70
+ # [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb)
71
+ # for additional information.
72
+ #
73
+ # Configuring a Ruby stdlib logger:
74
+ #
75
+ # ```ruby
76
+ # require "logger"
77
+ #
78
+ # module MyLogger
79
+ # LOGGER = Logger.new $stderr, level: Logger::WARN
80
+ # def logger
81
+ # LOGGER
82
+ # end
83
+ # end
84
+ #
85
+ # # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
86
+ # module GRPC
87
+ # extend MyLogger
88
+ # end
89
+ # ```x
90
+ #
58
91
  # ## Listing log entries
59
92
  #
60
93
  # Stackdriver Logging gathers log entries from many services, including
@@ -426,14 +426,14 @@ module Google
426
426
  e.insert_id = grpc.insert_id
427
427
  e.labels = Convert.map_to_hash(grpc.labels)
428
428
  e.payload = extract_payload(grpc)
429
- e.instance_variable_set "@resource",
429
+ e.instance_variable_set :@resource,
430
430
  Resource.from_grpc(grpc.resource)
431
- e.instance_variable_set "@http_request",
431
+ e.instance_variable_set :@http_request,
432
432
  HttpRequest.from_grpc(grpc.http_request)
433
- e.instance_variable_set "@operation",
433
+ e.instance_variable_set :@operation,
434
434
  Operation.from_grpc(grpc.operation)
435
435
  e.trace = grpc.trace
436
- e.instance_variable_set "@source_location",
436
+ e.instance_variable_set :@source_location,
437
437
  SourceLocation.from_grpc(
438
438
  grpc.source_location
439
439
  )
@@ -73,7 +73,9 @@ module Google
73
73
  grpc = @service.list_entries token: token, resources: @resources,
74
74
  filter: @filter, order: @order,
75
75
  max: @max, projects: @projects
76
- self.class.from_grpc grpc, @service
76
+ self.class.from_grpc grpc, @service, resources: @resources,
77
+ filter: @filter, order: @order,
78
+ max: @max, projects: @projects
77
79
  end
78
80
 
79
81
  ##
@@ -150,14 +152,14 @@ module Google
150
152
  Entry.from_grpc grpc_entry
151
153
  end)
152
154
  token = grpc_list.next_page_token
153
- token = nil if token == ""
154
- entries.instance_variable_set "@token", token
155
- entries.instance_variable_set "@service", service
156
- entries.instance_variable_set "@projects", projects
157
- entries.instance_variable_set "@resources", resources
158
- entries.instance_variable_set "@filter", filter
159
- entries.instance_variable_set "@order", order
160
- entries.instance_variable_set "@max", max
155
+ token = nil if token == "".freeze
156
+ entries.instance_variable_set :@token, token
157
+ entries.instance_variable_set :@service, service
158
+ entries.instance_variable_set :@projects, projects
159
+ entries.instance_variable_set :@resources, resources
160
+ entries.instance_variable_set :@filter, filter
161
+ entries.instance_variable_set :@order, order
162
+ entries.instance_variable_set :@max, max
161
163
  entries
162
164
  end
163
165
 
@@ -72,7 +72,8 @@ module Google
72
72
  ensure_service!
73
73
  grpc = @service.list_logs token: token, resource: @resource,
74
74
  max: @max
75
- self.class.from_grpc grpc, @service
75
+ self.class.from_grpc grpc, @service, resource: @resource,
76
+ max: @max
76
77
  end
77
78
 
78
79
  ##
@@ -132,11 +133,11 @@ module Google
132
133
  def self.from_grpc grpc_list, service, resource: nil, max: nil
133
134
  logs = new(Array(grpc_list.log_names))
134
135
  token = grpc_list.next_page_token
135
- token = nil if token == ""
136
- logs.instance_variable_set "@token", token
137
- logs.instance_variable_set "@service", service
138
- logs.instance_variable_set "@resource", resource
139
- logs.instance_variable_set "@max", max
136
+ token = nil if token == "".freeze
137
+ logs.instance_variable_set :@token, token
138
+ logs.instance_variable_set :@service, service
139
+ logs.instance_variable_set :@resource, resource
140
+ logs.instance_variable_set :@max, max
140
141
  logs
141
142
  end
142
143
 
@@ -72,7 +72,7 @@ module Google
72
72
  return nil unless next?
73
73
  ensure_service!
74
74
  grpc = @service.list_metrics token: token, max: @max
75
- self.class.from_grpc grpc, @service
75
+ self.class.from_grpc grpc, @service, @max
76
76
  end
77
77
 
78
78
  ##
@@ -148,10 +148,10 @@ module Google
148
148
  Metric.from_grpc grpc_metric, service
149
149
  end)
150
150
  token = grpc_list.next_page_token
151
- token = nil if token == ""
152
- metrics.instance_variable_set "@token", token
153
- metrics.instance_variable_set "@service", service
154
- metrics.instance_variable_set "@max", max
151
+ token = nil if token == "".freeze
152
+ metrics.instance_variable_set :@token, token
153
+ metrics.instance_variable_set :@service, service
154
+ metrics.instance_variable_set :@max, max
155
155
  metrics
156
156
  end
157
157
 
@@ -95,7 +95,7 @@ module Google
95
95
  # Done if Google::Cloud.configure.use_logging is explicitly false
96
96
  return if Google::Cloud.configure.use_logging == false
97
97
 
98
- # Verify credentials and set use_error_reporting to false if
98
+ # Verify credentials and set use_logging to false if
99
99
  # credentials are invalid
100
100
  unless valid_credentials? Logging.configure.project_id,
101
101
  Logging.configure.keyfile
@@ -114,7 +114,9 @@ module Google
114
114
  gcp_config = rails_config.google_cloud
115
115
  log_config = gcp_config.logging
116
116
 
117
- Cloud.configure.use_logging ||= gcp_config.use_logging
117
+ if Cloud.configure.use_logging.nil?
118
+ Cloud.configure.use_logging = gcp_config.use_logging
119
+ end
118
120
  Logging.configure do |config|
119
121
  config.project_id ||= config.project
120
122
  config.project_id ||= log_config.project_id || log_config.project
@@ -73,15 +73,15 @@ module Google
73
73
  # @private New ResourceDescriptor from a
74
74
  # Google::Api::MonitoredResourceDescriptor object.
75
75
  def self.from_grpc grpc
76
- r = new
77
- r.instance_variable_set "@type", grpc.type
78
- r.instance_variable_set "@name", grpc.display_name
79
- r.instance_variable_set "@description", grpc.description
80
76
  labels = Array(grpc.labels).map do |g|
81
77
  LabelDescriptor.from_grpc g
82
78
  end
83
- r.instance_variable_set "@labels", labels
84
- r
79
+ new.tap do |r|
80
+ r.instance_variable_set :@type, grpc.type
81
+ r.instance_variable_set :@name, grpc.display_name
82
+ r.instance_variable_set :@description, grpc.description
83
+ r.instance_variable_set :@labels, labels
84
+ end
85
85
  end
86
86
 
87
87
  ##
@@ -124,11 +124,11 @@ module Google
124
124
  type_sym = { STRING: :string,
125
125
  BOOL: :boolean,
126
126
  INT64: :integer }[grpc.value_type]
127
- l = new
128
- l.instance_variable_set "@key", grpc.key
129
- l.instance_variable_set "@type", type_sym
130
- l.instance_variable_set "@description", grpc.description
131
- l
127
+ new.tap do |l|
128
+ l.instance_variable_set :@key, grpc.key
129
+ l.instance_variable_set :@type, type_sym
130
+ l.instance_variable_set :@description, grpc.description
131
+ end
132
132
  end
133
133
  end
134
134
  end
@@ -75,7 +75,7 @@ module Google
75
75
  list_grpc = @service.list_resource_descriptors(
76
76
  token: token, max: @max
77
77
  )
78
- self.class.from_grpc list_grpc, @service
78
+ self.class.from_grpc list_grpc, @service, @max
79
79
  end
80
80
 
81
81
  ##
@@ -154,10 +154,10 @@ module Google
154
154
  ResourceDescriptor.from_grpc grpc
155
155
  end)
156
156
  token = grpc_list.next_page_token
157
- token = nil if token == ""
158
- rds.instance_variable_set "@token", token
159
- rds.instance_variable_set "@service", service
160
- rds.instance_variable_set "@max", max
157
+ token = nil if token == "".freeze
158
+ rds.instance_variable_set :@token, token
159
+ rds.instance_variable_set :@service, service
160
+ rds.instance_variable_set :@max, max
161
161
  rds
162
162
  end
163
163
 
@@ -71,7 +71,7 @@ module Google
71
71
  return nil unless next?
72
72
  ensure_service!
73
73
  list_grpc = @service.list_sinks token: token, max: @max
74
- self.class.from_grpc list_grpc, @service
74
+ self.class.from_grpc list_grpc, @service, @max
75
75
  end
76
76
 
77
77
  ##
@@ -147,10 +147,10 @@ module Google
147
147
  Sink.from_grpc grpc, service
148
148
  end)
149
149
  token = grpc_list.next_page_token
150
- token = nil if token == ""
151
- sinks.instance_variable_set "@token", token
152
- sinks.instance_variable_set "@service", service
153
- sinks.instance_variable_set "@max", max
150
+ token = nil if token == "".freeze
151
+ sinks.instance_variable_set :@token, token
152
+ sinks.instance_variable_set :@service, service
153
+ sinks.instance_variable_set :@max, max
154
154
  sinks
155
155
  end
156
156
 
@@ -17,7 +17,7 @@ module Google
17
17
  # rubocop:disable LineLength
18
18
 
19
19
  ##
20
- # # Ruby Client for Stackdriver Logging API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
20
+ # # Ruby Client for Stackdriver Logging API ([GA](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
21
21
  #
22
22
  # [Stackdriver Logging API][Product Documentation]:
23
23
  # Writes log entries and manages your Stackdriver Logging configuration.
@@ -63,4 +63,4 @@ module Google
63
63
  end
64
64
  end
65
65
  end
66
- end
66
+ end
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Logging
19
- VERSION = "1.5.0".freeze
19
+ VERSION = "1.5.1".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: 1.5.0
4
+ version: 1.5.1
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: 2018-02-28 00:00:00.000000000 Z
12
+ date: 2018-07-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core
@@ -290,7 +290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
290
290
  version: '0'
291
291
  requirements: []
292
292
  rubyforge_project:
293
- rubygems_version: 2.7.6
293
+ rubygems_version: 2.7.7
294
294
  signing_key:
295
295
  specification_version: 4
296
296
  summary: API Client library for Stackdriver Logging