Skip to content

Fix Elixir 1.19 Logger deprecation warnings - #28

Merged
slashmili merged 1 commit into
slashmili:mainfrom
digitalninjae:fix-deprecation-warnings
May 25, 2026
Merged

slashmili merged 1 commit into
slashmili:mainfrom
digitalninjae:fix-deprecation-warnings

Conversation

@digitalninjae

Copy link
Copy Markdown
Contributor

What

Resolves the deprecation warnings emitted under Elixir 1.19 / recent
Logger versions. No behavior change beyond the warnings going away.

Why

The legacy :gen_event backend layer delivers warning events using the
old :warn level name. Passing that atom to Logger.compare_levels/2
prints the log level :warn is deprecated, use :warning instead on
every warning-level log, flooding application logs.

Changes

  • Normalize the legacy :warn level to :warning before it reaches
    Logger.compare_levels/2 (in both handle_event/2 and the configured
    min_level); match level_to_priority/1 on :warning.
  • Remove the deprecated $levelpad token from the default format
    pattern, moduledoc, README, and example/dev configs.
  • Replace the single-quoted '#Ref' charlist with the ~c"#Ref" sigil
    in the JSON formatter.
  • Add a warning-level log to the test suite, which previously only
    exercised debug/info/error and so never hit the :warn path.

Out of scope

The :backends config key is also deprecated, but that originates from
consumer config and reflects the larger :gen_event → :logger handler
migration. Happy to discuss that separately if you'd like.

Verified

mix test passes (now including a warning-level log); the three
deprecation warnings no longer appear during compile or test runs.

@slashmili slashmili left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @digitalninjae !

overall lgtm. could you please remove the comments for the private function.

Comment thread lib/ex_syslogger.ex Outdated
The legacy :gen_event backend layer delivers warning events using the
old :warn level name. Passing that atom to Logger.compare_levels/2
emitted "the log level :warn is deprecated, use :warning instead" on
every warning-level log. Normalize :warn to :warning before comparing
(in both handle_event/2 and the configured min_level) and match
level_to_priority/1 on :warning.

Also clears two related deprecations surfaced on Elixir 1.19:
- Remove the deprecated $levelpad token from the default format
  pattern, moduledoc, README, and example/dev configs.
- Replace the single-quoted '#Ref' charlist with the ~c"#Ref" sigil
  in the JSON formatter.

Add a warning-level log to the test suite, which previously only
exercised debug/info/error and so never triggered the :warn path.
@digitalninjae
digitalninjae force-pushed the fix-deprecation-warnings branch from 6956eef to aa9e3d0 Compare May 22, 2026 22:19
@digitalninjae
digitalninjae requested a review from slashmili May 24, 2026 03:20
@slashmili
slashmili merged commit cd2b6ad into slashmili:main May 25, 2026
0 of 6 checks passed
@slashmili

Copy link
Copy Markdown
Owner

Thanks!

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