Skip to content

Commit

Permalink
Proscribe poor logging practices
Browse files Browse the repository at this point in the history
  • Loading branch information
quantum5 committed Sep 29, 2019
1 parent cf9cf32 commit 18816e7
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
max-line-length = 120
application-import-names = dmoj,judge,django_ace,event_socket_server
import-order-style = pycharm
enable-extensions = G
ignore =
W504, # line break occurred after a binary operator
# allow only generator_stop and annotations future imports
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: python
python: 3.7
install: pip install flake8 flake8-import-order flake8-future-import flake8-commas
install: pip install flake8 flake8-import-order flake8-future-import flake8-commas flake8-logging-format
script:
- flake8 --version
- flake8
Expand Down
5 changes: 2 additions & 3 deletions dmoj/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@

@task_failure.connect()
def celery_failure_log(sender, task_id, exception, traceback, *args, **kwargs):
logger.exception('Celery Task {task_name}: {task_id} on {hostname}'.format(
task_name=sender.name, task_id=task_id, hostname=socket.gethostname(),
), exc_info=(type(exception), exception, traceback))
logger.error('Celery Task %s: %s on %s', sender.name, task_id, socket.gethostname(), # noqa: G201
exc_info=(type(exception), exception, traceback))
4 changes: 2 additions & 2 deletions judge/utils/pwned.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ def _get_pwned(prefix):
),
)
response.raise_for_status()
except requests.RequestException as e:
except requests.RequestException:
# Gracefully handle timeouts and HTTP error response codes.
log.warning('Skipped Pwned Passwords check due to error: %r', e)
log.warning('Skipped Pwned Passwords check due to error', exc_info=True)
return None

results = {}
Expand Down
4 changes: 2 additions & 2 deletions judge/utils/texoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ def query_texoid(self, document, hash):
if e.response.status == 400:
logger.error('Texoid failed to render: %s\n%s', document, e.response.text)
else:
logger.exception('Failed to connect to texoid for: %s' % document)
logger.exception('Failed to connect to texoid for: %s', document)
return
except Exception:
logger.exception('Failed to connect to texoid for: %s' % document)
logger.exception('Failed to connect to texoid for: %s', document)
return

try:
Expand Down

0 comments on commit 18816e7

Please sign in to comment.