Skip to content

fix logger reset for the shell plugin#2428

Merged
ferd merged 1 commit into
erlang:masterfrom
galdor:master
Nov 17, 2020
Merged

fix logger reset for the shell plugin#2428
ferd merged 1 commit into
erlang:masterfrom
galdor:master

Conversation

@galdor

@galdor galdor commented Nov 15, 2020

Copy link
Copy Markdown
Contributor

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