summaryrefslogtreecommitdiff
path: root/lib/plugins/logger.ex
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/plugins/logger.ex39
1 files changed, 20 insertions, 19 deletions
diff --git a/lib/plugins/logger.ex b/lib/plugins/logger.ex
index 46c2a5b..1418ddc 100644
--- a/lib/plugins/logger.ex
+++ b/lib/plugins/logger.ex
@@ -32,52 +32,53 @@ defmodule Nola.Plugins.Logger do
end
def handle_info(info, state) do
- Logger.debug("logger_plugin: unhandled info: #{inspect info}")
+ Logger.debug("logger_plugin: unhandled info: #{inspect(info)}")
{:noreply, state}
end
def log(entry, state) do
case Couch.post(@couch_db, format_to_db(entry)) do
{:ok, id, _rev} ->
- Logger.debug("logger_plugin: saved: #{inspect id}")
+ Logger.debug("logger_plugin: saved: #{inspect(id)}")
state
+
error ->
- Logger.error("logger_plugin: save failed: #{inspect error}")
+ Logger.error("logger_plugin: save failed: #{inspect(error)}")
end
rescue
e ->
- Logger.error("logger_plugin: rescued processing for #{inspect entry}: #{inspect e}")
+ Logger.error("logger_plugin: rescued processing for #{inspect(entry)}: #{inspect(e)}")
Logger.error(Exception.format(:error, e, __STACKTRACE__))
state
catch
e, b ->
- Logger.error("logger_plugin: catched processing for #{inspect entry}: #{inspect e}")
+ Logger.error("logger_plugin: catched processing for #{inspect(entry)}: #{inspect(e)}")
Logger.error(Exception.format(e, b, __STACKTRACE__))
state
end
def format_to_db(msg = %Nola.Message{id: id}) do
- channel = cond do
- msg.channel -> msg.channel
- msg.account -> msg.account.id
- msg.sender -> msg.sender.nick
- true -> nil
- end
+ channel =
+ cond do
+ msg.channel -> msg.channel
+ msg.account -> msg.account.id
+ msg.sender -> msg.sender.nick
+ true -> nil
+ end
- id = [msg.network, channel, id]
- |> Enum.filter(& &1)
- |> Enum.join(":")
+ id =
+ [msg.network, channel, id]
+ |> Enum.filter(& &1)
+ |> Enum.join(":")
- %{"_id" => id,
+ %{
+ "_id" => id,
"type" => "nola.message:v1",
"object" => %Nola.Message{msg | meta: Map.delete(msg.meta, :from)}
}
end
def format_to_db(anything) do
- %{"_id" => FlakeId.get(),
- "type" => "object",
- "object" => anything}
+ %{"_id" => FlakeId.get(), "type" => "object", "object" => anything}
end
-
end