Skip to content

feat: Migrate from error_logger to OTP logger module#173

Open
kinyoklion wants to merge 3 commits intomainfrom
rlamb/SDK-1446/logger-migration
Open

feat: Migrate from error_logger to OTP logger module#173
kinyoklion wants to merge 3 commits intomainfrom
rlamb/SDK-1446/logger-migration

Conversation

@kinyoklion
Copy link
Copy Markdown
Member

@kinyoklion kinyoklion commented Mar 18, 2026

Replace all error_logger calls (info_msg, warning_msg, error_msg) with their logger equivalents (logger:info, logger:warning, logger:error).

All logger calls include #{domain => [ldclient]} metadata, enabling users to filter SDK logs using standard logger configuration. The logger module also automatically attaches module, function, and line metadata.

This addresses GitHub issue #160. The error_logger module is marked for eventual removal from OTP, and logger (available since OTP 21) is the recommended replacement. All supported OTP versions (24+) include logger.

I am concerned about one situation. Users with custom error_logger report handlers that specifically capture SDK logs should switch to logger handlers instead. Example:

    logger:add_handler(my_handler, my_module, #{
        filter_default => stop,
        filters => [{ldclient_only,
            {fun logger_filters:domain/2, {log, sub, [ldclient]}}}]
    })

Basically if they were already working around the fact we didn't support logger, then that workaround would break.


Note

Medium Risk
Mostly a mechanical logging migration, but it can change log routing/formatting and may break consumers relying on error_logger report handlers to capture SDK logs.

Overview
Migrates SDK logging from error_logger (info_msg/warning_msg/error_msg) to OTP logger (info/warning/error) across client, evaluation, update processors, event pipeline, and storage backends.

All new log calls attach #{domain => [ldclient]} metadata to enable domain-based filtering, and the test suite is updated to capture logs via a custom logger handler instead of an error_logger report handler.

Written by Cursor Bugbot for commit a7d7962. This will update automatically on new commits. Configure here.

Replace all error_logger calls (info_msg, warning_msg, error_msg) with
their logger equivalents (logger:info, logger:warning, logger:error)
across 18 source files and 3 test files.

All logger calls include #{domain => [ldclient]} metadata, enabling
users to filter SDK logs using standard logger configuration. The logger
module also automatically attaches module, function, and line metadata.

This addresses GitHub issue #160. The error_logger module is marked for
eventual removal from OTP, and logger (available since OTP 21) is the
recommended replacement. All supported OTP versions (24+) include logger.

Migration notes for users:
- Users with custom error_logger report handlers that specifically
  capture SDK logs should switch to logger handlers instead. Example:

    logger:add_handler(my_handler, my_module, #{
        filter_default => stop,
        filters => [{ldclient_only,
            {fun logger_filters:domain/2, {log, sub, [ldclient]}}}]
    })

- Elixir users benefit automatically: SDK logs now appear as native
  Elixir Logger events with proper metadata instead of wrapped
  error_logger reports.
- No public API changes. This is an internal logging infrastructure
  change only.
@kinyoklion kinyoklion requested a review from a team as a code owner March 18, 2026 23:44
The default logger_formatter templates already append newlines, so
trailing ~n in format strings produced double-newlines. Additionally,
one 2-argument logger:info call had ~n in a literal string where it
would not be expanded at all (unlike error_logger which processed all
strings through io_lib:format).
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Pre-existing bug: the format string used C-style %p instead of Erlang's
~p for the Uri argument. This caused io_lib:format to fail at runtime,
silently losing the "Failed to connect to update server" warning message.
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