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

fix logger reset for the shell plugin #2428

Merged
merged 1 commit into from
Nov 17, 2020
Merged

fix logger reset for the shell plugin #2428

merged 1 commit into from
Nov 17, 2020

Conversation

galdor
Copy link
Contributor

@galdor galdor commented Nov 15, 2020

The shell plugin has to reset the logger by fetching its configuration and
re-applying it later. In the current state, maybe_reset_logger/1 will only
re-apply part of the configuration (the config key), which does not include
other settings such as filters and formatters.

The effect can be demonstrated by adding filters or formatters to ~/.erlang
and running rebar3 shell on any project (without any --config argument, this
one reload the logger env; updating the kernel/logger environment in
~/.erlang fixes it).

For example:

logger:set_handler_config(default, #{formatter => {logger_formatter,
                                                   #{template => ["> ", msg, "\n"]}}}).

This patch makes sure the default handler is re-created with its entire
original configuration.

The shell plugin has to reset the logger by fetching its configuration and
re-applying it later. In the current state, `maybe_reset_logger/1` will only
re-apply part of the configuration (the `config` key), which does not include
other settings such as filters and formatters.

The effect can be demonstrated by adding filters or formatters to `~/.erlang`
and running rebar3 shell on any project (without any --config argument, this
one reload the logger env; updating the kernel/logger environment in
`~/.erlang` fixes it).

For example:
```erlang
logger:set_handler_config(default, #{formatter => {logger_formatter,
                                                   #{template => ["> ", msg, "\n"]}}}).
```

This patch makes sure the default handler is re-created with its entire
original configuration.
@ferd ferd merged commit 19308ee into erlang:master Nov 17, 2020
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