Skip to content

Move off lager onto OTP logger - #16

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
Contributor

Fourteen call sites across four modules. The dependency also still pointed at basho/lager — the pre-fork organisation — on a rolling master branch.

Two adjustments beyond the mechanical swap:

  • folsom_graphite_app used error_logger:info_msg, the deprecated API that only reached a log file because lager intercepted it.
  • Three format strings ended in ~n, which lager's formatter already newlined — that produced a blank line.

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.

Note: building this repo standalone needs url."https://github.com/".insteadOf "git://github.com/" — folsom pulls bear over the git:// protocol GitHub disabled in 2021. Pre-existing, unrelated.

Fourteen call sites across four modules. The dependency also still pointed at basho/lager, the pre-fork organisation, on a rolling master branch. Two extras: folsom_graphite_app used the deprecated error_logger:info_msg, which only reached a log file because lager intercepted it; and three format strings ended in ~n, which lager formatter already newlined.

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