ExActivity
Logs activity to your database - using Ecto. You have control what you log, in a structured way.
Warning: this is still very alpha
Installation
Add ex_activity
and your Ecto database adapter to your list of dependencies in mix.exs
:
def deps do
[
{:ex_activity, "~> 0.1.6"},
{:mariaex, "~> 0.8.2"}
]
end
Then run mix deps.get to fetch the dependencies.
Next provide configuration for the repo ExActivity will use:
config :ex_activity,
adapter: Ecto.Adapters.MySQL,
username: "sqluser",
password: "",
database: "app_db",
hostname: "localhost",
charset: "utf8mb4",
Usage
Provide a filled out ExActivity.Log
struct and pass it to the log method:
ExActivity.log(%ExActivity.Log{
type: "api_call",
action: "UserController/list" ,
result: "user_count: 10"
})
Documentation
The docs can be found at https://hexdocs.pm/ex_activity.
Why?
We are new to the Phoenix/Elixir club, and were set in our ways when it comes to logging. We prefer to log important actions to a database, in a unified way. While we use the default Elixir logger to log general stuff to services like PaperTrail, we needed something more. We used ActivityLog in Laravel before, so we made ExActivity.
TODO
- [ ] improve documentation
- [ ] ip / user_agent from conn
License
ExActivity is Copyright © 2017 Jack+Joe. It is free software, and may be redistributed under the terms specified in the LICENSE file.