Skip to content

Move off lager onto OTP logger - #21

Open
tas50 wants to merge 1 commit into
chef:mainfrom
tas50:lager-removal
Open

tas50 wants to merge 1 commit into
chef:mainfrom
tas50:lager-removal

Conversation

@tas50

@tas50 tas50 commented Sep 7, 2026

Copy link
Copy Markdown

One call site (oc_httpc_worker). Removes the lager dep and its parse transform.

Why

lager is unmaintained and reaches inside OTP in ways that are not supported:

  • lager_stdlib.erl is a verbatim copy of unexported OTP stdlib functions — "Functions from Erlang OTP distribution that are really useful but aren't exported", Copyright Ericsson AB 1996-2009 — and lager_format.erl is a fork of io_lib_format (1996-2011-2012).
  • lager_app starts the deprecated error_logger, installs OTP's internal error_logger module as a logger handler by hand rather than through error_logger:add_report_handler, then calls logger:remove_handler(default) to delete OTP's own default handler. Its own comment calls this "a band-aid" for OTP 21.
  • error_logger_lager_h pattern-matches OTP's internal {error_report,_} / {info_report,_} shapes.
  • lager_transform rewrites the AST at compile time.

Upstream's last commit is e6b3178 (2023-11-02), so none of that is being re-synced.

?LOG_* macros rather than logger:Level/2 calls: the macros capture module, function and line, which is the job lager_transform did.

Coordination

chef-server pins this library and cannot remove lager from its own services while this one still declares the dependency. Companion PRs exist on the other two libraries it pulls lager through.

Verified with rebar3 compile from a clean _build in an erlang:26 container.

One call site (oc_httpc_worker).

lager is unmaintained and reaches inside OTP in ways that are not
supported: lager_stdlib.erl is a verbatim copy of unexported OTP stdlib
functions (Copyright Ericsson AB 1996-2009) and lager_format.erl a fork
of io_lib_format (1996-2011-2012); lager_app starts the deprecated
error_logger, installs OTP internal error_logger module as a logger
handler by hand rather than through error_logger:add_report_handler,
then calls logger:remove_handler(default) to remove OTP own default
handler -- its own comment calls that "a band-aid" for OTP 21; and
error_logger_lager_h pattern-matches OTP internal report tuples.
Upstream last commit is e6b3178 (2023-11-02), so none of that is being
re-synced.

The ?LOG_* macros rather than logger:Level/2 calls: the macros capture
module, function and line, which is the job lager parse transform used
to do.

chef-server pins this library and cannot remove lager from its own
services while this one still declares the dependency.

Verified with rebar3 compile from a clean _build in an erlang:26 container.

Signed-off-by: Tim Smith <tim@mondoo.com>
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.

1 participant