Journal Signals and Receivers

Signals for the Smarter Journal.

smarter.lib.journal.signals.journal_entries_listed = <django.dispatch.dispatcher.Signal object>

Signal sent when journal entries are listed through the journal api.

Parameters:
  • user (User) – The user who listed them.

  • count (int) – The number of entries that match the request’s search.

Example:

journal_entries_listed.send(sender=self.__class__, user=request.user, count=count)
smarter.lib.journal.signals.journal_entry_accessed = <django.dispatch.dispatcher.Signal object>

Signal sent when a journal entry is read through the journal api.

Journal entries hold credentials and user content, so every read is signaled.

Parameters:
  • journal (SAMJournal) – The journal entry that was read.

  • user (User) – The user who read it.

Example:

journal_entry_accessed.send(sender=self.__class__, journal=journal, user=request.user)
smarter.lib.journal.signals.journal_entry_created = <django.dispatch.dispatcher.Signal object>

Signal sent when a journaled response has written its journal entry.

Parameters:

journal (SAMJournal) – The new journal entry.

Example:

journal_entry_created.send(sender=self.__class__, journal=journal)
smarter.lib.journal.signals.journal_entry_failed = <django.dispatch.dispatcher.Signal object>

Signal sent when a journaled response could not write its journal entry.

The response is returned without a key.

Parameters:
  • user (User) – The user who made the request, or None.

  • thing (str) – The journal’s thing, e.g. Guardrail.

  • command (str) – The journal’s command, e.g. apply.

  • status (int) – The response’s http status.

  • request (HttpRequest) – The request.

  • response (dict) – The response’s JSON, or None if it could not be serialized.

  • error (Exception) – The error that prevented the entry from being saved.

Example:

journal_entry_failed.send(
    sender=self.__class__,
    user=user,
    thing=thing,
    command=command,
    status=status,
    request=request,
    response=response,
    error=e,
)

Django signal receivers for the Smarter Journal.

They only log. A journal entry’s request and response documents hold credentials and user content, so the receivers log an entry’s key, thing, command and status code, never its documents.

smarter.lib.journal.receivers.error_logger = <Logger smarter.lib.journal.receivers (DEBUG)>

Logs whatever the waffle switches, for a journal entry that could not be saved.

smarter.lib.journal.receivers.journal_entries_listed_receiver(sender, user, count, **kwargs)[source]

Signal receiver for journal_entries_listed signal.

smarter.lib.journal.receivers.journal_entry_accessed_receiver(sender, journal, user, **kwargs)[source]

Signal receiver for journal_entry_accessed signal.

smarter.lib.journal.receivers.journal_entry_created_receiver(sender, journal, **kwargs)[source]

Signal receiver for journal_entry_created signal.

smarter.lib.journal.receivers.journal_entry_failed_receiver(sender, user, thing, command, status, request, response, error, **kwargs)[source]

Signal receiver for journal_entry_failed signal.

It logs at error level, whatever the waffle switches, because a missing journal entry is a gap in an audit record. Operators monitor the logs for could not create journal entry.

smarter.lib.journal.receivers.samjournal_post_delete(sender, instance, **kwargs)[source]

Signal receiver for deleted of SAMJournal model.

smarter.lib.journal.receivers.samjournal_post_save(sender, instance, created, **kwargs)[source]

Signal receiver for created/saved of SAMJournal model.