Skip to content

Commit

Permalink
Merge a1fad28 into c39d004
Browse files Browse the repository at this point in the history
  • Loading branch information
felixrindt committed Jun 28, 2023
2 parents c39d004 + a1fad28 commit 83234a9
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions ephios/modellogging/log.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import contextlib
import itertools
import threading
from typing import Dict
Expand All @@ -16,8 +15,6 @@


class BaseLogConfig:
log_entry_context_manager = contextlib.nullcontext

def initial_log_recorders(self, instance):
"""
Initial log recorders are always added after model __init__.
Expand Down Expand Up @@ -45,6 +42,13 @@ def object_to_attach_logentries_to(self, instance):
"""
return type(instance), instance.pk

def save_logentry(self, logentry: LogEntry):
"""
Save the logentry. Overwrite this method to process the logentry
bevore saving.
"""
logentry.save()


class ModelFieldsLogConfig(BaseLogConfig):
def __init__(self, unlogged_fields=None, attach_to_func=None, initial_recorders_func=None):
Expand Down Expand Up @@ -156,8 +160,7 @@ def update_log(instance, action_type: InstanceActionType):
data=log_data,
)

with config.log_entry_context_manager():
logentry.save()
config.save_logentry(logentry)
instance._current_logentry = logentry


Expand Down

0 comments on commit 83234a9

Please sign in to comment.