test(data/model): test action logging

This commit is contained in:
EvB 2017-02-27 23:57:40 -05:00
parent 6916d82e0d
commit 625bd66b42
3 changed files with 69 additions and 3 deletions

View file

@ -116,10 +116,12 @@ def log_action(kind_name, user_or_organization_name, performer=None, repository=
LogEntry.create(kind=kind, account=account, performer=performer,
repository=repository, ip=ip, metadata_json=metadata_json,
datetime=timestamp)
except PeeweeException:
except PeeweeException as ex:
if kind_name is 'pull_repo' and config.app_config.get('ALLOW_PULLS_WITHOUT_STRICT_LOGGING'):
logger.warning('log_action failed: kind=%s account=%s user=%s repo=%s ip=%s metadata=%s',
kind_name, account, performer, repository, ip, metadata_json)
logger.warning('log_action failed',
extra={'exception': ex, 'action_kind': kind, 'account': account,
'performer': performer, 'repository': repository, 'ip': ip,
'metadata_json': metadata_json, 'datetime': timestamp})
else:
raise