From de2036b19bb3a56d209b30b6898d795004a8d3f4 Mon Sep 17 00:00:00 2001 From: Sergi Delgado Segura Date: Fri, 14 Feb 2020 12:42:47 +0100 Subject: [PATCH] Fixes cli console log levels so Cryptographer's sensitive info is only logged in disk --- common/cryptographer.py | 2 +- common/logger.py | 4 ++-- common/tools.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/cryptographer.py b/common/cryptographer.py index 8cac45f..c701f5f 100644 --- a/common/cryptographer.py +++ b/common/cryptographer.py @@ -78,7 +78,7 @@ class Cryptographer: sk = sha256(unhexlify(secret)).digest() nonce = bytearray(12) - logger.info("Encrypting blob", sk=hexlify(sk).decode(), nonce=hexlify(nonce).decode(), blob=blob.data) + logger.debug("Encrypting blob", sk=hexlify(sk).decode(), nonce=hexlify(nonce).decode(), blob=blob.data) # Encrypt the data cipher = ChaCha20Poly1305(sk) diff --git a/common/logger.py b/common/logger.py index b175ebf..136b330 100644 --- a/common/logger.py +++ b/common/logger.py @@ -60,7 +60,7 @@ class Logger: def debug(self, msg, **kwargs): """ - Logs an ``DEBUG`` level message to stdout and file. + Logs a ``DEBUG`` level message to stdout and file. Args: msg (:obj:`str`): the message to be logged. @@ -84,7 +84,7 @@ class Logger: def warning(self, msg, **kwargs): """ - Logs an ``WARNING`` level message to stdout and file. + Logs a ``WARNING`` level message to stdout and file. Args: msg (:obj:`str`): the message to be logged. diff --git a/common/tools.py b/common/tools.py index 0c131da..55dfe09 100644 --- a/common/tools.py +++ b/common/tools.py @@ -129,10 +129,10 @@ def setup_logging(log_file_path, log_name_prefix): # Create the file logger f_logger = logging.getLogger("{}_file_log".format(log_name_prefix)) - f_logger.setLevel(logging.INFO) + f_logger.setLevel(logging.DEBUG) fh = logging.FileHandler(log_file_path) - fh.setLevel(logging.INFO) + fh.setLevel(logging.DEBUG) fh_formatter = logging.Formatter("%(message)s") fh.setFormatter(fh_formatter) f_logger.addHandler(fh)