diff --git a/lib/poison_endoder_list.ex b/lib/poison_endoder_list.ex index 48ac9bc..9eed805 100644 --- a/lib/poison_endoder_list.ex +++ b/lib/poison_endoder_list.ex @@ -1,36 +1,36 @@ -defimpl Poison.Encoder, for: List do - alias Poison.{Encoder, Pretty} - - use Pretty - - @compile :inline - @compile :inline_list_funcs - - def encode([], _options), do: "[]" - - def encode(list, options) do - encode(list, pretty(options), options) - end - - def encode([head | string], pretty, options) when is_binary(string) do - encode([head, string], pretty, options) - end - - def encode(list, false, options) do - [?[, tl(:lists.foldr(&[?,, Encoder.encode(&1, options) | &2], [], list)), ?]] - end - - def encode(list, true, options) do - indent = indent(options) - offset = offset(options) + indent - options = offset(options, offset) - - [ - "[\n", - tl(:lists.foldr(&[",\n", spaces(offset), Encoder.encode(&1, options) | &2], [], list)), - ?\n, - spaces(offset - indent), - ?] - ] - end -end +# defimpl Poison.Encoder, for: List do +# alias Poison.{Encoder, Pretty} + +# use Pretty + +# @compile :inline +# @compile :inline_list_funcs + +# def encode([], _options), do: "[]" + +# def encode(list, options) do +# encode(list, pretty(options), options) +# end + +# def encode([head | string], pretty, options) when is_binary(string) do +# encode([head, string], pretty, options) +# end + +# def encode(list, false, options) do +# [?[, tl(:lists.foldr(&[?,, Encoder.encode(&1, options) | &2], [], list)), ?]] +# end + +# def encode(list, true, options) do +# indent = indent(options) +# offset = offset(options) + indent +# options = offset(options, offset) + +# [ +# "[\n", +# tl(:lists.foldr(&[",\n", spaces(offset), Encoder.encode(&1, options) | &2], [], list)), +# ?\n, +# spaces(offset - indent), +# ?] +# ] +# end +# end diff --git a/lib/slack_logger_backend/format_helper.ex b/lib/slack_logger_backend/format_helper.ex index 8c8be13..2ef09d6 100644 --- a/lib/slack_logger_backend/format_helper.ex +++ b/lib/slack_logger_backend/format_helper.ex @@ -21,11 +21,13 @@ defmodule SlackLoggerBackend.FormatHelper do ] |> Enum.reject(&is_nil/1) + message = messge_to_string(detail.message) + {:ok, json} = %{ attachments: [ %{ - fallback: "An #{detail.level} level event has occurred: #{detail.message}", + fallback: "An #{detail.level} level event has occurred: #{message}", pretext: detail.message, fields: fields } @@ -49,4 +51,24 @@ defmodule SlackLoggerBackend.FormatHelper do } end end + + defp messge_to_string(a) when is_binary(a) do + a + end + + defp messge_to_string([a]) do + messge_to_string(a) + end + + defp messge_to_string(["\nState: " | _]) do + "" + end + + defp messge_to_string([a | b]) do + messge_to_string([messge_to_string(a) <> messge_to_string(b)]) + end + + defp messge_to_string(a) do + inspect(a) + end end