Skip to content

Commit 51a9314

Browse files
committed
Avoid forcing string interpolation when logging
This avoids doing extra work when a message is too low level to be displayed and exposes the full values so log handlers like Raven/Sentry can intelligently aggregate or display richer messages
1 parent 7142f83 commit 51a9314

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

bagit.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ def make_bag(bag_dir, bag_info=None, processes=1, checksum=None):
8080
the bag_info dictionary.
8181
"""
8282
bag_dir = os.path.abspath(bag_dir)
83-
logger.info("creating bag for directory %s" % bag_dir)
83+
logger.info("creating bag for directory %s", bag_dir)
8484
# assume md5 checksum if not specified
8585
if not checksum:
8686
checksum = ['md5']
8787

8888
if not os.path.isdir(bag_dir):
89-
logger.error("no such bag directory %s" % bag_dir)
89+
logger.error("no such bag directory %s", bag_dir)
9090
raise RuntimeError("no such bag directory %s" % bag_dir)
9191

9292
old_dir = os.path.abspath(os.path.curdir)
@@ -114,18 +114,18 @@ def make_bag(bag_dir, bag_info=None, processes=1, checksum=None):
114114
if os.path.abspath(f) == temp_data:
115115
continue
116116
new_f = os.path.join(temp_data, f)
117-
logger.info("moving %s to %s" % (f, new_f))
117+
logger.info("moving %s to %s", f, new_f)
118118
os.rename(f, new_f)
119119

120-
logger.info("moving %s to %s" % (temp_data, 'data'))
120+
logger.info("moving %s to %s", temp_data, 'data')
121121
os.rename(temp_data, 'data')
122122

123123
# permissions for the payload directory should match those of the
124124
# original directory
125125
os.chmod('data', os.stat(cwd).st_mode)
126126

127127
for c in checksum:
128-
logger.info("writing manifest-%s.txt" % c)
128+
logger.info("writing manifest-%s.txt", c)
129129
Oxum = _make_manifest('manifest-%s.txt' % c, 'data', processes, c)
130130

131131
logger.info("writing bagit.txt")
@@ -714,7 +714,7 @@ def _make_tag_file(bag_info_path, bag_info):
714714

715715

716716
def _make_manifest(manifest_file, data_dir, processes, algorithm='md5'):
717-
logger.info('writing manifest with %s processes' % processes)
717+
logger.info('writing manifest with %s processes', processes)
718718

719719
if algorithm == 'md5':
720720
manifest_line = _manifest_line_md5

0 commit comments

Comments
 (0)