Skip to content

7.0.0

Choose a tag to compare

@AndrewDryga AndrewDryga released this 06 Apr 21:09
· 14 commits to master since this release
59660c9

What's Changed

  • JSON encoder can be used with Elixir 1.18 by @altjohndev #146
  • Add Formatter.new/1 callback to simplify creating and configuring formatters by @ruslandoga #145. An additional benefit of this fix is that now the formatter configuration is only built once and not on each logger call, which should improve performance for some of the logger features. A similar Redactor.new/1 is also added to redactors behaviour.
  • Fixed a crash when handling improper lists by @martosaur in #149
  • Fixed a crash in LoggerJSON.Formatters.Datadog when logging GenServer crash reports by @wjwitek #148
  • Basic formatter now includes module.function/airty in the logged messages by @ppeerttu #138
  • GoogleCloud formatter now will attempt to read project_id from environment variables if it's not set explicitly
  • GoogleCloud formatter will report all :emergency, :alert, :critical and :error messages to Google Cloud Error Reporter by default
  • Binary encoder performance is improved (thanks to @josevalim for suggestions)

Upgrade instructions

Use new/1 in config/runtime.exs to set up the formatter:

config :logger, :default_handler,
--   formatter: {LoggerJSON.Formatters.Basic, [metadata: [:request_id]]}
++   formatter: LoggerJSON.Formatters.Basic.new(metadata: [:request_id])

Notice that the application and dependencies code are not available in config.exs so if it's where you configured the logging, you have two options:

  1. Move it to runtime.exs. This one is recommended because it will also reduce the amount of work the logger needs to do for each log entry;
  2. Upgrade to v7.0.1 and leave everything as is.

or in application.ex

-- :logger.update_handler_config(:default, :formatter, {Basic, []})
++ formatter = LoggerJSON.Formatters.Basic.new()
++ :logger.update_handler_config(:default, :formatter, formatter)