smpallen99 / whatwasit

Track changes to your Ecto models
MIT License
63 stars 8 forks source link

Add log file support (fail2ban and other log tools) #13

Closed Eiji7 closed 8 years ago

Eiji7 commented 8 years ago

If log file path was specified in configuration (for all tracked changes - dynamic, umbrella apps etc). Example: On %{date} %{what} with id %{id} was %{action} by '%{whodoneit_name}' (id: %{whodoneit_id}). where: date: when what: for example article id: for example Article id action: one of: ["create", "destroy", "update"] whodoneit_name: for example John whodoneit_id: for example John's id

Optionally (in options): log_formatter_module (if not specified use default formatter).

defmodule MyProject.LogFormatter
    def format(what_was_it) do
        # returns: {:ok, result} tuple where result is log string
    end
end

Why? For example:

  1. fail2ban or other third-party program - for example: rule to ban ip (matched with: whodoneit_id - same ip and same author/user) from which created too more entries (spam bot using REST API).
  2. Somebody may not have accesss to database (company restrictions) - he only want to get all IP addresses (or last activity date) for John (grep by regex where for example whodoneit_id is 5). Here I mean server admin/user, not project web admin or project developer.
smpallen99 commented 8 years ago

Good idea. I'm thinking this could be accomplished with a configurable callback hook. This way, you would add any processing you like when a new version record is generated.