google-cloud-logging 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -59,14 +59,14 @@ module Google
59
59
  # insert the Middleware.
60
60
  def self.init_middleware app
61
61
  project_id = Logging.configure.project_id
62
- keyfile = Logging.configure.keyfile
62
+ credentials = Logging.configure.credentials
63
63
  resource_type = Logging.configure.monitored_resource.type
64
64
  resource_labels = Logging.configure.monitored_resource.labels
65
65
  log_name = Logging.configure.log_name
66
66
  labels = Logging.configure.labels
67
67
 
68
- logging = Google::Cloud::Logging.new project: project_id,
69
- keyfile: keyfile
68
+ logging = Google::Cloud::Logging.new project_id: project_id,
69
+ credentials: credentials
70
70
  resource =
71
71
  Logging::Middleware.build_monitored_resource resource_type,
72
72
  resource_labels
@@ -112,27 +112,30 @@ module Google
112
112
  # configuration.
113
113
  def self.merge_rails_config rails_config # rubocop:disable AbcSize
114
114
  gcp_config = rails_config.google_cloud
115
- logging_config = gcp_config.logging
115
+ log_config = gcp_config.logging
116
116
 
117
117
  Cloud.configure.use_logging ||= gcp_config.use_logging
118
118
  Logging.configure do |config|
119
- config.project_id ||= logging_config.project_id ||
120
- gcp_config.project_id
121
- config.keyfile ||= logging_config.keyfile || gcp_config.keyfile
122
- config.log_name ||= logging_config.log_name
123
- config.labels ||= logging_config.labels
124
- config.log_name_map ||= logging_config.log_name_map
119
+ config.project_id ||= config.project
120
+ config.project_id ||= log_config.project_id || log_config.project
121
+ config.project_id ||= gcp_config.project_id || gcp_config.project
122
+ config.credentials ||= config.keyfile
123
+ config.credentials ||= log_config.credentials || log_config.keyfile
124
+ config.credentials ||= gcp_config.credentials || gcp_config.keyfile
125
+ config.log_name ||= log_config.log_name
126
+ config.labels ||= log_config.labels
127
+ config.log_name_map ||= log_config.log_name_map
125
128
  config.monitored_resource.type ||=
126
- logging_config.monitored_resource.type
129
+ log_config.monitored_resource.type
127
130
  config.monitored_resource.labels ||=
128
- logging_config.monitored_resource.labels.to_h
131
+ log_config.monitored_resource.labels.to_h
129
132
  end
130
133
  end
131
134
 
132
135
  ##
133
136
  # Fallback to default config values if config parameters not provided.
134
137
  def self.init_default_config
135
- Logging.configure.project_id ||= Logging::Project.default_project_id
138
+ Logging.configure.project_id ||= Logging.default_project_id
136
139
  Logging.configure.log_name ||= Middleware::DEFAULT_LOG_NAME
137
140
  end
138
141
 
@@ -73,7 +73,8 @@ module Google
73
73
  return nil unless next?
74
74
  ensure_service!
75
75
  list_grpc = @service.list_resource_descriptors(
76
- token: token, max: @max)
76
+ token: token, max: @max
77
+ )
77
78
  self.class.from_grpc list_grpc, @service
78
79
  end
79
80
 
@@ -165,7 +166,7 @@ module Google
165
166
  ##
166
167
  # Raise an error unless an active service is available.
167
168
  def ensure_service!
168
- fail "Must have active service" unless @service
169
+ raise "Must have active service" unless @service
169
170
  end
170
171
  end
171
172
  end
@@ -44,7 +44,8 @@ module Google
44
44
  timeout: timeout,
45
45
  client_config: client_config,
46
46
  lib_name: "gccl",
47
- lib_version: Google::Cloud::Logging::VERSION)
47
+ lib_version: Google::Cloud::Logging::VERSION
48
+ )
48
49
  end
49
50
  attr_accessor :mocked_logging
50
51
 
@@ -56,7 +57,8 @@ module Google
56
57
  timeout: timeout,
57
58
  client_config: client_config,
58
59
  lib_name: "gccl",
59
- lib_version: Google::Cloud::Logging::VERSION)
60
+ lib_version: Google::Cloud::Logging::VERSION
61
+ )
60
62
  end
61
63
  attr_accessor :mocked_sinks
62
64
 
@@ -68,7 +70,8 @@ module Google
68
70
  timeout: timeout,
69
71
  client_config: client_config,
70
72
  lib_name: "gccl",
71
- lib_version: Google::Cloud::Logging::VERSION)
73
+ lib_version: Google::Cloud::Logging::VERSION
74
+ )
72
75
  end
73
76
  attr_accessor :mocked_metrics
74
77
 
@@ -158,13 +161,9 @@ module Google
158
161
  end
159
162
  end
160
163
 
161
- def create_sink name, destination, filter, version, start_time: nil,
162
- end_time: nil, unique_writer_identity: nil
164
+ def create_sink name, destination, filter, unique_writer_identity: nil
163
165
  sink = Google::Logging::V2::LogSink.new({
164
- name: name, destination: destination, filter: filter,
165
- output_version_format: version,
166
- start_time: time_to_timestamp(start_time),
167
- end_time: time_to_timestamp(end_time)
166
+ name: name, destination: destination, filter: filter
168
167
  }.delete_if { |_, v| v.nil? })
169
168
 
170
169
  execute do
@@ -178,13 +177,12 @@ module Google
178
177
  execute { sinks.get_sink sink_path(name), options: default_options }
179
178
  end
180
179
 
181
- def update_sink name, destination, filter, version, start_time: nil,
182
- end_time: nil, unique_writer_identity: nil
183
- sink = Google::Logging::V2::LogSink.new({
184
- name: name, destination: destination, filter: filter,
185
- output_version_format: version,
186
- start_time: time_to_timestamp(start_time),
187
- end_time: time_to_timestamp(end_time) }.delete_if { |_, v| v.nil? })
180
+ def update_sink name, destination, filter, unique_writer_identity: nil
181
+ sink = Google::Logging::V2::LogSink.new(
182
+ {
183
+ name: name, destination: destination, filter: filter
184
+ }.delete_if { |_, v| v.nil? }
185
+ )
188
186
 
189
187
  execute do
190
188
  sinks.update_sink sink_path(name), sink,
@@ -214,9 +212,10 @@ module Google
214
212
  end
215
213
 
216
214
  def create_metric name, filter, description
217
- metric = Google::Logging::V2::LogMetric.new({
218
- name: name, description: description,
219
- filter: filter }.delete_if { |_, v| v.nil? })
215
+ metric = Google::Logging::V2::LogMetric.new(
216
+ { name: name, description: description,
217
+ filter: filter }.delete_if { |_, v| v.nil? }
218
+ )
220
219
 
221
220
  execute do
222
221
  metrics.create_log_metric project_path, metric,
@@ -231,9 +230,10 @@ module Google
231
230
  end
232
231
 
233
232
  def update_metric name, description, filter
234
- metric = Google::Logging::V2::LogMetric.new({
235
- name: name, description: description,
236
- filter: filter }.delete_if { |_, v| v.nil? })
233
+ metric = Google::Logging::V2::LogMetric.new(
234
+ { name: name, description: description,
235
+ filter: filter }.delete_if { |_, v| v.nil? }
236
+ )
237
237
 
238
238
  execute do
239
239
  metrics.update_log_metric metric_path(name), metric,
@@ -122,76 +122,101 @@ module Google
122
122
  end
123
123
 
124
124
  ##
125
- # The log entry version used when exporting log entries from this sink.
126
- # This version does not have to correspond to the version of the log
127
- # entry when it was written to Stackdriver Logging.
125
+ # **Deprecated.** The log entry version used when exporting log entries
126
+ # from this sink. This version does not have to correspond to the
127
+ # version of the log entry when it was written to Stackdriver Logging.
128
+ #
129
+ # @deprecated The v2 format is used by default and cannot be changed.
128
130
  def version
129
- @grpc.output_version_format
131
+ warn "[DEPRECATION] version is deprecated."
132
+ :V2
130
133
  end
131
134
 
132
135
  ##
133
- # Updates the log entry version used when exporting log entries from
134
- # this sink. This version does not have to correspond to the version of
135
- # the log entry when it was written to Stackdriver Logging. Accepted
136
- # values are `:VERSION_FORMAT_UNSPECIFIED`, `:V2`, and `:V1`.
137
- def version= version
138
- @grpc.output_version_format = self.class.resolve_version(version)
136
+ # **Deprecated.** Updates the log entry version used when exporting log
137
+ # entries from this sink. This version does not have to correspond to
138
+ # the version of the log entry when it was written to Stackdriver
139
+ # Logging. Accepted values are `:VERSION_FORMAT_UNSPECIFIED`, `:V2`, and
140
+ # `:V1`.
141
+ #
142
+ # @deprecated The v2 format is used by default and cannot be changed.
143
+ def version= _version
144
+ warn "[DEPRECATION] version= is deprecated and will be ignored."
139
145
  end
140
146
 
141
147
  ##
142
148
  # Helper to determine if the sink's version is
143
149
  # `VERSION_FORMAT_UNSPECIFIED`.
150
+ #
151
+ # @deprecated The v2 format is used by default and cannot be changed.
144
152
  def unspecified?
145
- !(v1? || v2?)
153
+ warn "[DEPRECATION] unspecified? is deprecated."
154
+ false
146
155
  end
147
156
 
148
157
  ##
149
158
  # Helper to determine if the sink's version is `V2`.
159
+ #
160
+ # @deprecated The v2 format is used by default and cannot be changed.
150
161
  def v2?
151
- version == :V2
162
+ warn "[DEPRECATION] v2? is deprecated."
163
+ true
152
164
  end
153
165
 
154
166
  ##
155
167
  # Helper to determine if the sink's version is `V1`.
168
+ #
169
+ # @deprecated The v2 format is used by default and cannot be changed.
156
170
  def v1?
157
- version == :V1
171
+ warn "[DEPRECATION] v1? is deprecated."
172
+ false
158
173
  end
159
174
 
160
175
  ##
161
- # The time at which this sink will begin exporting log entries. If this
162
- # value is present, then log entries are exported only if `start_at`
163
- # is less than the log entry's timestamp. Optional.
176
+ # **Deprecated.** The time at which this sink will begin exporting log
177
+ # entries. If this value is present, then log entries are exported only
178
+ # if `start_at` is less than the log entry's timestamp. Optional.
179
+ #
180
+ # @deprecated This field is ignored when creating or updating sinks.
164
181
  def start_at
165
- timestamp_to_time @grpc.start_time
182
+ warn "[DEPRECATION] start_at is deprecated."
183
+ nil
166
184
  end
167
- alias_method :start_time, :start_at
185
+ alias start_time start_at
168
186
 
169
187
  ##
170
- # Sets the time at which this sink will begin exporting log entries. If
171
- # this value is present, then log entries are exported only if
172
- # `start_at` is less than the log entry's timestamp. Optional.
173
- def start_at= new_start_at
174
- @grpc.start_time = time_to_timestamp new_start_at
188
+ # **Deprecated.** Sets the time at which this sink will begin exporting
189
+ # log entries. If this value is present, then log entries are exported
190
+ # only if `start_at` is less than the log entry's timestamp. Optional.
191
+ #
192
+ # @deprecated This field is ignored when creating or updating sinks.
193
+ def start_at= _new_start_at
194
+ warn "[DEPRECATION] start_at= is deprecated and will be ignored."
175
195
  end
176
- alias_method :start_time=, :start_at=
196
+ alias start_time= start_at=
177
197
 
178
198
  ##
179
- # Time at which this sink will stop exporting log entries. If this
180
- # value is present, then log entries are exported only if the log
181
- # entry's timestamp is less than `end_at`. Optional.
199
+ # **Deprecated.** Time at which this sink will stop exporting log
200
+ # entries. If this value is present, then log entries are exported only
201
+ # if the log entry's timestamp is less than `end_at`. Optional.
202
+ #
203
+ # @deprecated This field is ignored when creating or updating sinks.
182
204
  def end_at
183
- timestamp_to_time @grpc.end_time
205
+ warn "[DEPRECATION] end_at is deprecated."
206
+ nil
184
207
  end
185
- alias_method :end_time, :end_at
208
+ alias end_time end_at
186
209
 
187
210
  ##
188
- # Sets the time at which this sink will stop exporting log entries. If
189
- # this value is present, then log entries are exported only if the log
190
- # entry's timestamp is less than `end_at`. Optional.
191
- def end_at= new_end_at
192
- @grpc.end_time = time_to_timestamp new_end_at
211
+ # **Deprecated.** Sets the time at which this sink will stop exporting
212
+ # log entries. If this value is present, then log entries are exported
213
+ # only if the log entry's timestamp is less than `end_at`. Optional.
214
+ #
215
+ # @deprecated This field is ignored when creating or updating sinks.
216
+ def end_at= _new_end_at
217
+ warn "[DEPRECATION] end_at= is deprecated and will be ignored."
193
218
  end
194
- alias_method :end_time=, :end_at=
219
+ alias end_time= end_at=
195
220
 
196
221
  ##
197
222
  # An IAM identity (a service account or group) that will write exported
@@ -224,8 +249,7 @@ module Google
224
249
  def save unique_writer_identity: nil
225
250
  ensure_service!
226
251
  @grpc = service.update_sink \
227
- name, destination, filter, version,
228
- start_time: start_at, end_time: end_at,
252
+ name, destination, filter,
229
253
  unique_writer_identity: unique_writer_identity
230
254
  end
231
255
 
@@ -236,7 +260,7 @@ module Google
236
260
  ensure_service!
237
261
  @grpc = service.get_sink name
238
262
  end
239
- alias_method :refresh!, :reload!
263
+ alias refresh! reload!
240
264
 
241
265
  ##
242
266
  # Permanently deletes the logs-based sink.
@@ -265,23 +289,13 @@ module Google
265
289
  end
266
290
  end
267
291
 
268
- ##
269
- # @private Convert a version value to the gRPC enum value.
270
- def self.resolve_version version
271
- ver = version.to_s.upcase.to_sym
272
- ver = Google::Logging::V2::LogSink::VersionFormat.resolve ver
273
- return ver if ver
274
- Google::Logging::V2::LogSink::VersionFormat:: \
275
- VERSION_FORMAT_UNSPECIFIED
276
- end
277
-
278
292
  protected
279
293
 
280
294
  ##
281
295
  # @private Raise an error unless an active connection to the service is
282
296
  # available.
283
297
  def ensure_service!
284
- fail "Must have active connection to service" unless service
298
+ raise "Must have active connection to service" unless service
285
299
  end
286
300
 
287
301
  ##
@@ -159,7 +159,7 @@ module Google
159
159
  ##
160
160
  # Raise an error unless an active service is available.
161
161
  def ensure_service!
162
- fail "Must have active service" unless @service
162
+ raise "Must have active service" unless @service
163
163
  end
164
164
  end
165
165
  end
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Logging
19
- VERSION = "1.4.0"
19
+ VERSION = "1.5.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: 1.4.0
4
+ version: 1.5.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: 2017-12-19 00:00:00.000000000 Z
12
+ date: 2018-02-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core
@@ -17,28 +17,28 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '1.1'
20
+ version: '1.2'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '1.1'
27
+ version: '1.2'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: stackdriver-core
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '1.2'
34
+ version: '1.3'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '1.2'
41
+ version: '1.3'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: google-gax
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -127,16 +127,16 @@ dependencies:
127
127
  name: rubocop
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
- - - "<="
130
+ - - "~>"
131
131
  - !ruby/object:Gem::Version
132
- version: 0.35.1
132
+ version: 0.50.0
133
133
  type: :development
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
- - - "<="
137
+ - - "~>"
138
138
  - !ruby/object:Gem::Version
139
- version: 0.35.1
139
+ version: 0.50.0
140
140
  - !ruby/object:Gem::Dependency
141
141
  name: simplecov
142
142
  requirement: !ruby/object:Gem::Requirement
@@ -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.3
293
+ rubygems_version: 2.7.6
294
294
  signing_key:
295
295
  specification_version: 4
296
296
  summary: API Client library for Stackdriver Logging