From 97e23e86f0f6e74216d5a328f0cba17d6f3dabe6 Mon Sep 17 00:00:00 2001 From: Timothy Hobbs Date: Wed, 24 Oct 2018 17:36:01 +0200 Subject: [PATCH] Small refactor get_email.py --- helpdesk/management/commands/get_email.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/helpdesk/management/commands/get_email.py b/helpdesk/management/commands/get_email.py index 5ae13079..79a575b2 100755 --- a/helpdesk/management/commands/get_email.py +++ b/helpdesk/management/commands/get_email.py @@ -83,18 +83,17 @@ def process_email(quiet=False): allow_email_submission=True): logger = logging.getLogger('django.helpdesk.queue.' + q.slug) - if not q.logging_type or q.logging_type == 'none': + logging_types = { + 'info': logging.INFO, + 'warn': logging.WARN, + 'error': logging.ERROR, + 'crit': logging.CRITICAL, + 'debug': logging.DEBUG, + } + if q.logging_type in logging_types: + logger.setLevel(logging_types[q.logging_type]) + elif not q.logging_type or q.logging_type == 'none': logging.disable(logging.CRITICAL) # disable all messages - elif q.logging_type == 'info': - logger.setLevel(logging.INFO) - elif q.logging_type == 'warn': - logger.setLevel(logging.WARN) - elif q.logging_type == 'error': - logger.setLevel(logging.ERROR) - elif q.logging_type == 'crit': - logger.setLevel(logging.CRITICAL) - elif q.logging_type == 'debug': - logger.setLevel(logging.DEBUG) if quiet: logger.propagate = False # do not propagate to root logger that would log to console logdir = q.logging_dir or '/var/log/helpdesk/'