Packages
logger_json
5.1.4
7.0.4
7.0.3
7.0.2
7.0.1
7.0.0
6.2.1
6.2.0
6.0.3
6.0.2
6.0.1
6.0.0
6.0.0-rc.4
6.0.0-rc.3
6.0.0-rc.2
6.0.0-rc.1
6.0.0-rc.0
5.1.4
5.1.3
5.1.2
5.1.1
5.1.0
5.0.0
4.3.0
4.2.0
4.1.0
4.0.0
3.3.0
3.2.0
3.1.2
3.1.1
3.1.0
3.0.3
3.0.2
3.0.1
3.0.0
2.0.1
2.0.0
1.3.0
1.2.1
1.2.0
1.1.0
1.0.1
1.0.0
0.5.0
0.4.0
0.3.0
0.2.0
0.1.0
This package includes a set of :logger formatters designed to output logs in JSON format. It is compatible with a variety of log management systems that support JSON, including Google Cloud Logging and Error Reporting, Datadog, ElasticSearch, LogStash, FileBeat, and Kibana.
Current section
Files
Jump to
Current section
Files
lib/logger_json/formatter.ex
defmodule LoggerJSON.Formatter do
@moduledoc """
Behaviour that should be implemented by log formatters.
Example implementations can be found in `LoggerJSON.Formatters.GoogleCloudLogger` and
`LoggerJSON.Formatters.BasicLogger`.
"""
@doc """
Initialization callback. Ran on startup with the given `formatter_opts` list.
Returned list will be used as formatter_state in `format_event/6`.
"""
@callback init(Keyword.t()) :: term()
@doc """
Format event callback.
Returned map will be encoded to JSON.
"""
@callback format_event(
level :: Logger.level(),
msg :: Logger.message(),
ts :: Logger.Formatter.time(),
md :: [atom] | :all,
state :: map,
formatter_state :: map
) :: map | iodata() | %Jason.Fragment{}
end