From 591d2f89a1b16c5d679753e2a21ae196f78bdb7a Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Tue, 18 Feb 2020 17:05:11 +0100 Subject: [PATCH] audit: log event creation on save --- passbook/audit/models.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/passbook/audit/models.py b/passbook/audit/models.py index 8823dc8e3..168daa79d 100644 --- a/passbook/audit/models.py +++ b/passbook/audit/models.py @@ -100,7 +100,6 @@ class Event(UUIDModel): app = getmodule(stack()[_inspect_offset][0]).__name__ cleaned_kwargs = sanitize_dict(kwargs) event = Event(action=action.value, app=app, context=cleaned_kwargs) - LOGGER.debug("Created Audit event", action=action, context=cleaned_kwargs) return event def from_http( @@ -129,6 +128,12 @@ class Event(UUIDModel): raise ValidationError( "you may not edit an existing %s" % self._meta.model_name ) + LOGGER.debug( + "Created Audit event", + action=self.action, + context=self.context, + client_ip=self.client_ip, + ) return super().save(*args, **kwargs) class Meta: