Releases: Nebo15/logger_json
7.0.4
What's Changed
- Add indentation to the code snippet for docs by @RudolfMan in #160
- Google Cloud: Handle non-binary values in
format_affected_user/1by @raulpe7eira in #161
Full Changelog: 7.0.3...7.0.4
7.0.3
7.0.2
What's Changed
- Datadog: report
error.kindanderror.stackfor non-crash error+ logs by @aloukissas in #157
New Contributors
- @aloukissas made their first contribution in #157
Full Changelog: 7.0.1...7.0.2
7.0.1: Allow using config tuples from 6.0
This release restores support for the {FormatterModule, opts} tuple syntax in your config/config.exs, so upgrading from v6 to v7 won’t break existing setups. We added it mainly for users who configure their logger at compile‑time - before new/1 (or any application/dependencies code) is available.
That said, tuple‑based configs are invoked on every log entry, so it’s still best practice to move your formatter setup into config/runtime.exs where it runs once at startup. See 7.0.0 release notes for instructions.
7.0.0
What's Changed
- JSON encoder can be used with Elixir 1.18 by @altjohndev #146
- Add
Formatter.new/1callback 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 similarRedactor.new/1is 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_idfrom 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:
- 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; - 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)6.2.1
What's Changed
- fix: check if Decimal is loaded in encoder by @davidjulien in #135
Full Changelog: 6.2.0...6.2.1
6.2.0
- Added :encoder_opts formatter option which allows passing any options down to
Jasonencoder, eg. if you want to format the output during development. Thanks to @anthonator; - Keep native DateTime, Date and Time structs when encoding them. This prevents those structs from being logged as maps. Thanks to @imricardoramos;
- Always return :ok even if nothing is logged fixes a bug when plug logger is configured not to return anything. Thanks to @adamu;
- A new
metadataoption is added which allows reading configuration from the default logger or any other place in the application environment. The downside of using it is that the application environment will be read on every logged message (since there is no way to init the state of:loggerformatter); - Replace μs with us because unicode is not always available in log aggregators. This value then also will be copied to appropriate provider-specific field. And separately copy it to an appropriate field depending on the formatter used. Thanks to @bvobart;
- Various docs, typos, and typespec fixes. Thanks to @dvic, @moxley.
- Fix Task/GenServer exits correctly in Google Cloud Logger formatter. Thanks @BrentWheeldon.
6.0.3
- Improve exception structure when logged using
Elasticformatter; - Document usage of the
crash_reasonmetadata key across formatters.
6.0.2
Bugs
- Do not crash when
metadatais set tonil, we will assume that is an empty list instead; Elasticlogger did not writemessageand other keys when aconnwas present in the metadata.
6.0.1
- Fixed an issue where LoggerJSON will not compile in projects where Plus or Ecto are not added as a dependency