Skip to content

Commit

Permalink
Log output of cron to load ads from paris
Browse files Browse the repository at this point in the history
  • Loading branch information
brmzkw committed Feb 23, 2025
1 parent 9f2a4d4 commit 6e84cc3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion mesads/app/crons.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import functools
import io
from contextlib import redirect_stdout, redirect_stderr


from sentry_sdk import capture_exception

Expand Down Expand Up @@ -29,4 +32,9 @@ class ImportDataForParis(CronJobBase):

@sentry_exceptions
def do(self):
call_command("import_last_update_file_from_paris")
# Redirect stdout and stderr to a buffer to capture the output of the
# command. By returning it, django-cron will log it in the database.
buf = io.StringIO()
with redirect_stdout(buf), redirect_stderr(buf):
call_command("import_last_update_file_from_paris")
return buf.getvalue()

0 comments on commit 6e84cc3

Please sign in to comment.