Skip to content

Emit log events as :warning instead of :warn#23

Open
jvf wants to merge 1 commit intosmpallen99:masterfrom
sonnen:fix-emitted-level
Open

Emit log events as :warning instead of :warn#23
jvf wants to merge 1 commit intosmpallen99:masterfrom
sonnen:fix-emitted-level

Conversation

@jvf
Copy link

@jvf jvf commented Feb 6, 2024

In Elixir v1.15 a deprecation warning is emitted if the deprecated log level shortcut warn is:

warning: the log level :warn is deprecated, use :warning instead
  (logger 1.15.7) lib/logger.ex:1137: Logger.elixir_level_to_erlang_level/1
  (logger 1.15.7) lib/logger.ex:591: Logger.compare_levels/2
  (syslog 1.0.0) lib/syslog.ex:37: Logger.Backends.Syslog.handle_event/2
  (stdlib 5.2) gen_event.erl:814: :gen_event.server_update/4
  (stdlib 5.2) gen_event.erl:796: :gen_event.server_notify/4
  (stdlib 5.2) gen_event.erl:538: :gen_event.handle_msg/6

At the same time the Logger passes the log level as warn to the old-style logger backends. Presumably for backwards compatibility. It thus falls to the logger backend to use the correct level identifier when emitting events.

The syslog backend is such a logger backend. This PR adds a code snippet to transform the received level warn to warning.

cc: @harunzengin @weisslj

Convert :warn to :warning to avoid getting a deprecation warning from
Logger every time a :warning is emitted. The deprecation warning was
added in Elixir v1.15.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments