LogForwarder
A simple LogForwarder backend as a supervisor which forwards logs to another server.
Installation
def deps do
[
{:log_forwarder, "~> 0.2.1"}
]
endConfiguration
Our config.exs would have an entry similar to this:
config :log_forwarder, config:
host: "localhost",
port: 24224,
prefix: "LogForwarder",
retry_times: 10,
attributes: ~w(level error ...)LogForwarder supports the following configuration values:
- host
- port
- prefix
- retry_times
- attributes
How to use
The typical use of LogForwarder is to set up using a Supervisor. It can be handled automatically:
-
Add following into
application.ex:
def start(_type, _args) do
Supervisor.start_link(
[ supervisor(LogForwarder, []),
# other Supervisor or Worker
]
)
endEnsure
LogForwarderis started before your app:def application do [applications: [:cachex]] endThen:
defmodule SampleModule do import LogForwarder def sample_func() do # do something ... send_log("api_tag", :info, data) end end
Todo
- Add unit test