Skip to content

Commit 14ef6bd

Browse files
Use lazy logging format (#5398)
1 parent 27f5bcc commit 14ef6bd

42 files changed

Lines changed: 158 additions & 147 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

couch/datadog_checks/couch/couch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def _build_system_metrics(self, data, tags, prefix='couchdb.erlang'):
238238
self.gauge("{0}.{1}.size".format(prefix, key), val['count'], queue_tags)
239239
else:
240240
self.agent_check.log.debug(
241-
"Queue %s does not have a key 'count'. It will be ignored." % queue
241+
"Queue %s does not have a key 'count'. It will be ignored.", queue
242242
)
243243
else:
244244
self.gauge("{0}.{1}.size".format(prefix, key), val, queue_tags)
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# (C) Datadog, Inc. 2018-present
22
# All rights reserved
33
# Licensed under a 3-clause BSD style license (see LICENSE)
4-
#
54
__path__ = __import__('pkgutil').extend_path(__path__, __name__)

datadog_checks_downloader/datadog_checks/downloader/download.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def __download_with_tuf(self, target_relpath):
104104

105105
# Either the target has not been updated...
106106
if not len(updated_targets):
107-
logger.debug('{} has not been updated'.format(target_relpath))
107+
logger.debug('%s has not been updated', target_relpath)
108108
# or, it has been updated, in which case...
109109
else:
110110
# First, we use TUF to download and verify the target.
@@ -113,7 +113,7 @@ def __download_with_tuf(self, target_relpath):
113113
assert updated_target == target
114114
self.__updater.download_target(updated_target, self.__targets_dir)
115115

116-
logger.info('TUF verified {}'.format(target_relpath))
116+
logger.info('TUF verified %s', target_relpath)
117117

118118
target_abspath = os.path.join(self.__targets_dir, target_relpath)
119119
return target_abspath, target
@@ -185,7 +185,7 @@ def __load_root_layout(self, target_relpath):
185185
return root_layout, root_layout_pubkeys, root_layout_params
186186

187187
def __handle_in_toto_verification_exception(self, target_relpath, e):
188-
logger.exception('in-toto failed to verify {}'.format(target_relpath))
188+
logger.exception('in-toto failed to verify %s', target_relpath)
189189

190190
if isinstance(e, LinkNotFoundError) and str(e) == RevokedDeveloper.MSG:
191191
raise RevokedDeveloper(target_relpath, IN_TOTO_ROOT_LAYOUT)
@@ -211,7 +211,7 @@ def __in_toto_verify(self, inspection_packet, target_relpath):
211211
except Exception as e:
212212
self.__handle_in_toto_verification_exception(target_relpath, e)
213213
else:
214-
logger.info('in-toto verified {}'.format(target_relpath))
214+
logger.info('in-toto verified %s', target_relpath)
215215
finally:
216216
# Switch back to a parent directory we control, so that we can
217217
# safely delete temp dir.

directory/datadog_checks/directory/directory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def _get_stats(
133133
file_stat = file_entry.stat()
134134

135135
except OSError as ose:
136-
self.warning('DirectoryCheck: could not stat file {} - {}'.format(join(root, file_entry.name), ose))
136+
self.warning('DirectoryCheck: could not stat file %s - %s', join(root, file_entry.name), ose)
137137
else:
138138
# file specific metrics
139139
directory_bytes += file_stat.st_size

disk/datadog_checks/disk/disk.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,25 +263,25 @@ def _compile_pattern_filters(self, instance):
263263
device_blacklist_extras = []
264264
mount_point_blacklist_extras = []
265265

266-
deprecation_message = '`{old}` is deprecated and will be removed in 6.9. Please use `{new}` instead.'
266+
deprecation_message = '`%s` is deprecated and will be removed in 6.9. Please use `%s` instead.'
267267

268268
if 'excluded_filesystems' in instance:
269269
file_system_blacklist_extras.extend(
270270
'{}$'.format(pattern) for pattern in instance['excluded_filesystems'] if pattern
271271
)
272-
self.warning(deprecation_message.format(old='excluded_filesystems', new='file_system_blacklist'))
272+
self.warning(deprecation_message, 'excluded_filesystems', 'file_system_blacklist')
273273

274274
if 'excluded_disks' in instance:
275275
device_blacklist_extras.extend('{}$'.format(pattern) for pattern in instance['excluded_disks'] if pattern)
276-
self.warning(deprecation_message.format(old='excluded_disks', new='device_blacklist'))
276+
self.warning(deprecation_message, 'excluded_disks', 'device_blacklist')
277277

278278
if 'excluded_disk_re' in instance:
279279
device_blacklist_extras.append(instance['excluded_disk_re'])
280-
self.warning(deprecation_message.format(old='excluded_disk_re', new='device_blacklist'))
280+
self.warning(deprecation_message, 'excluded_disk_re', 'device_blacklist')
281281

282282
if 'excluded_mountpoint_re' in instance:
283283
mount_point_blacklist_extras.append(instance['excluded_mountpoint_re'])
284-
self.warning(deprecation_message.format(old='excluded_mountpoint_re', new='mount_point_blacklist'))
284+
self.warning(deprecation_message, 'excluded_mountpoint_re', 'mount_point_blacklist')
285285

286286
# Any without valid patterns will become None
287287
self._file_system_whitelist = self._compile_valid_patterns(self._file_system_whitelist, casing=re.I)

docker_daemon/test/test_docker_daemon.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def test_event_attributes_tag(self):
8282
"nginx:latest", detach=True, name='event-tags-test', entrypoint='/bin/false')
8383
log.debug('start nginx:latest with entrypoint /bin/false')
8484
DockerUtil().client.start(container_fail)
85-
log.debug('container exited with %s' % DockerUtil().client.wait(container_fail, 1))
85+
log.debug('container exited with %s', DockerUtil().client.wait(container_fail, 1))
8686
# Wait 1 second after exit so the event will be picked up
8787
from time import sleep
8888
sleep(1)
@@ -278,12 +278,12 @@ def setUp(self):
278278
self.docker_client.connect_container_to_network(cont['Id'], self.second_network)
279279

280280
for c in self.containers:
281-
log.info("Starting container: {0}".format(c))
281+
log.info("Starting container: %s", c)
282282
self.docker_client.start(c)
283283

284284
def tearDown(self):
285285
for c in self.containers:
286-
log.info("Stopping container: {0}".format(c))
286+
log.info("Stopping container: %s", c)
287287
self.docker_client.remove_container(c, force=True)
288288
self.docker_client.remove_network(self.second_network)
289289

@@ -829,8 +829,8 @@ def test_collect_exit_code(self):
829829
log.debug('start nginx:latest with entrypoint /bin/false')
830830
self.docker_client.start(container_ok)
831831
self.docker_client.start(container_fail)
832-
log.debug('container exited with %s' % self.docker_client.wait(container_ok, 1))
833-
log.debug('container exited with %s' % self.docker_client.wait(container_fail, 1))
832+
log.debug('container exited with %s', self.docker_client.wait(container_ok, 1))
833+
log.debug('container exited with %s', self.docker_client.wait(container_fail, 1))
834834
# After the container exits, we need to wait a second so the event isn't too recent
835835
# when the check runs, otherwise the event is not picked up
836836
from time import sleep

gitlab/datadog_checks/gitlab/gitlab.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def _check_health_endpoint(self, instance, check_type, tags):
110110

111111
if url is None:
112112
# Simply ignore this service check if not configured
113-
self.log.debug("gitlab_url not configured, service check {} skipped".format(check_type))
113+
self.log.debug("gitlab_url not configured, service check %s skipped", check_type)
114114
return
115115

116116
service_check_tags = self._service_check_tags(url)
@@ -121,7 +121,7 @@ def _check_health_endpoint(self, instance, check_type, tags):
121121
check_url = '{}/-/{}'.format(url, check_type)
122122

123123
try:
124-
self.log.debug("checking {} against {}".format(check_type, check_url))
124+
self.log.debug("checking %s against %s", check_type, check_url)
125125
r = self.http.get(check_url)
126126
if r.status_code != 200:
127127
self.service_check(
@@ -153,4 +153,4 @@ def _check_health_endpoint(self, instance, check_type, tags):
153153
raise
154154
else:
155155
self.service_check(service_check_name, OpenMetricsBaseCheck.OK, tags=service_check_tags)
156-
self.log.debug("gitlab check {} succeeded".format(check_type))
156+
self.log.debug("gitlab check %s succeeded", check_type)

gitlab_runner/datadog_checks/gitlab_runner/gitlab_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def _check_connectivity_to_master(self, instance, tags):
108108
service_check_tags.extend(tags)
109109

110110
try:
111-
self.log.debug("checking connectivity against {}".format(url))
111+
self.log.debug("checking connectivity against %s", url)
112112
r = self.http.get(url)
113113
if r.status_code != 200:
114114
self.service_check(

haproxy/datadog_checks/haproxy/haproxy.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def _collect_version_from_http(self, url):
200200
self.log.debug("unable to find HAProxy version info")
201201
else:
202202
version = re.search(r"HAProxy version ([^,]+)", raw_version).group(1)
203-
self.log.debug(u"HAProxy version is {}".format(version))
203+
self.log.debug("HAProxy version is %s", version)
204204
self.set_metadata('version', version)
205205

206206
def _fetch_socket_data(self, parsed_url):
@@ -577,14 +577,13 @@ def _process_status_metric(
577577
try:
578578
service, _, hostname, status = host_status
579579
except Exception:
580+
service, _, status = host_status
580581
if collect_status_metrics_by_host:
581582
self.warning(
582-
'`collect_status_metrics_by_host` is enabled but no host info\
583-
could be extracted from HAProxy stats endpoint for {0}'.format(
584-
service
585-
)
583+
'`collect_status_metrics_by_host` is enabled but no host info could be extracted from HAProxy '
584+
'stats endpoint for %s',
585+
service,
586586
)
587-
service, _, status = host_status
588587

589588
if self._is_service_excl_filtered(service, services_incl_filter, services_excl_filter):
590589
continue

ibm_db2/datadog_checks/ibm_db2/ibm_db2.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,9 @@ def query_custom(self):
480480
column_type = column.get('type')
481481
if not column_type: # no cov
482482
self.log.error(
483-
'Column field `type` is required for column `{}` '
484-
'of metric_prefix `{}`'.format(name, metric_prefix)
483+
'Column field `type` is required for column `%s` of metric_prefix `%s`',
484+
name,
485+
metric_prefix,
485486
)
486487
break
487488

@@ -490,16 +491,20 @@ def query_custom(self):
490491
else:
491492
if not hasattr(self, column_type):
492493
self.log.error(
493-
'Invalid submission method `{}` for metric column `{}` of '
494-
'metric_prefix `{}`'.format(column_type, name, metric_prefix)
494+
'Invalid submission method `%s` for metric column `%s` of metric_prefix `%s`',
495+
column_type,
496+
name,
497+
metric_prefix,
495498
)
496499
break
497500
try:
498501
metric_info.append(('{}.{}'.format(metric_prefix, name), float(value), column_type))
499502
except (ValueError, TypeError): # no cov
500503
self.log.error(
501-
'Non-numeric value `{}` for metric column `{}` of '
502-
'metric_prefix `{}`'.format(value, name, metric_prefix)
504+
'Non-numeric value `%s` for metric column `%s` of metric_prefix `%s`',
505+
value,
506+
name,
507+
metric_prefix,
503508
)
504509
break
505510

0 commit comments

Comments
 (0)