Commit 6fc26a35 authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

Improve log message and use lazy logging

parent 1ae8107b
......@@ -157,9 +157,11 @@ class Signature:
self.config = config
self.logger = logger
def log(self, message):
def log(self, message, *args):
if self.logger is not None:
self.logger.debug(message, *args)
elif args:
print(message % args)
......@@ -189,11 +191,11 @@ class Signature:
required_key_list=['timestamp'], strategy=strategy)
if download_metadata_dict:
self.log('File downloaded on temp %s' % path)
self.log('File downloaded in %s', path)
current_sha256 = self.get_file_hash(path)
if, required_key_list=['timestamp'],
strategy=strategy, is_sha256file=True):
self.log('File downloaded on temp. %s' % sha256path)
self.log('sha 256 downloaded in %s', sha256path)
with open(sha256path, 'rb') as f:
expected_sha256 =
......@@ -230,16 +232,16 @@ class Signature:
if shacache.upload(path=path,
self.log('Uploaded upload file to cache.')
self.log('Uploaded %s to cache (using %s key).', path, shacache.directory_key)
if shacache.upload(path=sha256path,
metadata_dict=metadata_dict, is_sha256file=True):
self.log('Uploaded sha256file file to cache.')
self.log('Uploaded %s to cache (using %s key).', sha256path, shacache.directory_key)
self.log('Fail to upload sha256file file to cache.')
self.log('Fail to upload file to cache.')
self.log('Fail to upload %s to cache.', path)
except Exception:
self.log('Unable to upload to cache:\n%s.' % traceback.format_exc())
self.log('Unable to upload to cache:\n%s.', traceback.format_exc())
def upload(self):
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment