django-auditlog icon indicating copy to clipboard operation
django-auditlog copied to clipboard

Make manual logging easier

Open jjkester opened this issue 9 years ago • 3 comments

(As pointed out in #36)

Proposed solution:

  • Make connecting signals optional (but do it by default) when registering a model
  • Create an easy to use method for creating log entries
    • This method should accept and old and new version of the same instance (which should be checked)
    • This method should determine the correct action
    • This method should allow users to override certain model fields (whether action and changes should be overridden is debatable)
    • This method may be applied elsewhere, for example replacing code in the current signal receivers
  • Investigate whether creating a context manager for with statements is useful
    • This context manager should be outputted by a factory which takes the object instance (and maybe other relevant things) as argument and automatically determine as much as realistically possible without doing black magic

Anyone is free to suggest other implementations as well as submit a pull request for any improvement on the main issue, regardless of the implementation. However, I reserve the right to decline and/or alter any submissions.

jjkester avatar Sep 22 '15 22:09 jjkester

I would be interested in this feature. Something similar to http://django-audit-log.readthedocs.org/en/latest/model_history.html#disabling-enabling-tracking-on-a-model-instance would be nice.

dawalama avatar Mar 10 '16 19:03 dawalama

Thanks for your suggestion. It is interesting to see what competing libraries are doing.

I am not comfortable with monkey patching model instances to keep some configuration data. This defeats the purpose of this app, personally I think the unobtrusiveness of it all makes this app stand out.

In my original post I suggested using a context manager for when things have to be logged. I think explicitly enable logging is better than explicitly disabling logging, which is kind of weird.

What are your thoughts on only doing explicit logging (so either all operations are logged or only the operations which are explicitly marked to be logged)? How would you feel about using a context manager or a wrapper function? No decision has been made about the implementation details, so suggestions are welcome.

jjkester avatar Mar 27 '16 13:03 jjkester

Moved to 0.5.0 release to quickly ship improvements for Django 1.10.

jjkester avatar Aug 02 '16 15:08 jjkester