diff --git a/ennstatus/api/functions.py b/ennstatus/api/functions.py --- a/ennstatus/api/functions.py +++ b/ennstatus/api/functions.py @@ -6,6 +6,8 @@ from datetime import datetime import pygeoip +from flask import current_app + from ennstatus.status.functions import _send_mail @@ -74,6 +76,7 @@ def check_json_format(server): def _send_offline_mail(server_name, last_updated): + current_app.logger.info('Sending tor status offline mail!') subject = '[Ennstatus] %s Tor status went offline' _send_mail(server_name, last_updated, subject) mail_cache[server_name] = datetime.utcnow() @@ -107,17 +110,24 @@ def update_server(server, ip): if server['tor_status'] == 'Offline': if server_name in mail_cache: + + current_app.logger.debug('Mail cache is %s' % str(mail_cache)) + send_date = mail_cache[server_name] now = datetime.utcnow() delta = now - send_date if delta.seconds <= 7200: + current_app.logger.debug('Server is in mail cache but not old enough to resend mail') return server else: + current_app.logger.debug('Server tor status is offline for more than 7200 seconds') _send_offline_mail(server_name, server['last_updated']) else: + current_app.logger.debug('Server is not in mail cache') _send_offline_mail(server_name, server['last_updated']) elif server_name in mail_cache: + current_app.logger.debug('Removing server from mail cache') del mail_cache[server_name] return server diff --git a/ennstatus/log.py b/ennstatus/log.py --- a/ennstatus/log.py +++ b/ennstatus/log.py @@ -24,7 +24,7 @@ def init_logging(app): rotating_file_handler.setLevel(logging.INFO) rotating_file_handler.setFormatter(logging_formatter) - if app.debug: + if app.debug or app.config['ENABLE_DEBUG_LOG']: second_rotating_file_handler = logging.handlers.RotatingFileHandler( 'log/ennstatus_debug.log', maxBytes=1300000,