Log history changes to console

This commit is contained in:
Tanner Collin 2021-11-29 02:18:58 +00:00
parent e8557cbf37
commit af3f4ac614
5 changed files with 18 additions and 5 deletions

View File

@ -421,6 +421,7 @@ class CardSerializer(serializers.ModelSerializer):
read_only_fields = [
'id',
'last_seen',
'last_seen_at',
'user',
]

View File

@ -69,7 +69,7 @@ def post_create_historical_record_callback(
is_admin=is_admin_director(history_user),
)
for change in changes:
for num, change in enumerate(changes):
change_old = str(change.old)
change_new = str(change.new)
@ -84,6 +84,18 @@ def post_create_historical_record_callback(
old=change_old,
new=change_new,
)
logger.info('History - {} changed {}\'s {} {}/{}: {} "{}" --> "{}"'.format(
history_user or 'System',
owner[0],
object_name,
num+1,
len(changes),
change.field,
change_old,
change_new,
))
except BaseException as e:
logger.error('History Signal - {} - {}'.format(e.__class__.__name__, e))
logger.info(str(sender))

View File

@ -24,5 +24,5 @@ class LoggingThrottle(throttling.BaseThrottle):
else:
data = None
logging.info('Request User: %s | %s %s | Data: %s', user, method, path, data)
logging.info('Request - User: %s | %s %s | Data: %s', user, method, path, data)
return True

View File

@ -158,7 +158,7 @@ def get_progress(request_id):
return cache.get('request-progress-' + request_id, [])
def set_progress(request_id, data):
logger.info('Request %s progress: %s', request_id, data)
logger.info('Progress - ID: %s | Status: %s', request_id, data)
progress = get_progress(request_id)
progress.append(data)
cache.set('request-progress-' + request_id, progress)

View File

@ -475,7 +475,7 @@ class DoorViewSet(viewsets.ViewSet, List):
except models.Member.DoesNotExist:
raise Http404
t = utils.now_alberta_tz().strftime('%Y-%m-%d %H:%M:%S, %a %I:%M %p')
logger.info('Time: {} - Name: {} {} ({})'.format(t, member.first_name, member.last_name, member.id))
logger.info('Scan - Time: {} | Name: {} {} ({})'.format(t, member.first_name, member.last_name, member.id))
utils_stats.calc_card_scans()
@ -651,7 +651,7 @@ class BackupView(views.APIView):
backup_user = secrets.BACKUP_TOKENS.get(auth_token, None)
if backup_user:
logger.info('Backup user: ' + backup_user['name'])
logger.info('Backup - User: ' + backup_user['name'])
backup_path = cache.get(backup_user['cache_key'], None)
if not backup_path: