logger: always do traceback when DEBUG var is True

related to #13
This commit is contained in:
pedro 2024-11-05 03:43:18 +01:00
parent e4124fb20b
commit 79a34c9b55
2 changed files with 7 additions and 3 deletions

View File

@ -58,8 +58,6 @@ class Command(BaseCommand):
self.devices.append(Build(s, self.user)) self.devices.append(Build(s, self.user))
move_json(p, self.user.institution.name) move_json(p, self.user.institution.name)
except Exception as err: except Exception as err:
if settings.DEBUG:
logger.exception("%s", err)
snapshot_id = s.get("uuid", "") snapshot_id = s.get("uuid", "")
txt = "It is not possible to parse snapshot: %s" txt = "Could not parse snapshot: %s"
logger.error(txt, snapshot_id) logger.error(txt, snapshot_id)

View File

@ -1,4 +1,5 @@
import logging import logging
from django.conf import settings
# Colors # Colors
RED = "\033[91m" RED = "\033[91m"
@ -24,6 +25,11 @@ class CustomFormatter(logging.Formatter):
record.msg = self.highlight_args(record.msg, record.args, color) record.msg = self.highlight_args(record.msg, record.args, color)
record.args = () record.args = ()
# provide trace when DEBUG config
if settings.DEBUG:
import traceback
print(traceback.format_exc())
return super().format(record) return super().format(record)
def highlight_args(self, message, args, color): def highlight_args(self, message, args, color):