Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve relative log_root to absolute on boot #557

Closed
paulo-ferraz-oliveira opened this issue Jun 8, 2021 · 1 comment
Closed

Resolve relative log_root to absolute on boot #557

paulo-ferraz-oliveira opened this issue Jun 8, 2021 · 1 comment

Comments

@paulo-ferraz-oliveira
Copy link
Contributor

paulo-ferraz-oliveira commented Jun 8, 2021

As per a recent discussion with @uwiger, on Slack, lager could be doing something like:

expand_lager_log_root() ->
    {ok, Root} = application:get_env(lager, log_root),
    case filename:pathtype(Root) of
        relative ->
            application:set_env(lager, log_root, filename:absname(Root));
        absolute ->
            ok
    end.

as a way to "lock" the log root to an absolute path. This makes for easier debugging, as a call to application:get_env(lager, log_root) would immediately tell us where the log is in the disk.

@mrallen1, @Vagabond, thoughts?

@uwiger
Copy link
Contributor

uwiger commented Jun 8, 2021

I just prepared to commit the following comment to the above code in our project. :)

%% See https://github.com/erlang-lager/lager/issues/557
%% There are different ways to ensure that the log root is a stable
%% absolute path (once initialized). This could also be done using
%% sys.config.src (e.g. `{log_root, "${ROOTDIR}/log"}`, but at the time
%% of writing, `rebar3 ct` doesn't support `sys_config_src`, and it gets messy
%% to support both types.
%%
%% This setup hook code will likely run after lager has started, but it still
%% fixes the log root for later. One possible scenario might be that someone
%% pecks around in an aeternity node shell, changes the current working directory
%% and forgets to restore it. This would effectively move the logical log_root
%% in lager, if the setting is a relative path (which is the default).
%%

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

No branches or pull requests

2 participants