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

rebar3 shell: implement various modes to print "booted" message #2513

Merged
merged 1 commit into from
Mar 16, 2021

Conversation

max-au
Copy link
Contributor

@max-au max-au commented Mar 10, 2021

This commit adds a parameter to rebar.config shell section:

{shell, [
    {apps, [megaco, tools, runtime_tools]},
    {log, info | debug}
]}.

This commit adds a parameter to rebar.config shell section:

    {shell, [
        {apps, [megaco, tools, runtime_tools]},
        {log, info | debug}
    ]}.

With 'info' (default), behaviour stays as before.
With 'debug', "===> Booted megaco" messages are printed with debug verbosity level,
and are available when rebar3 is run with DEBUG=1 environment variable.

Comment on lines 448 to 451
_ = [?INFO("Booted ~p", [App])
|| {ok, Booted} <- Res,
App <- Booted],
print_booted([App || {ok, Booted} <- Res, App <- Booted], BootMessageMode),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the thing we got with the current implementation is help when apps may get stuck or stalled in case of issues getting started. Otherwise if you have 12 apps to load and the 9th gets stuck, you never have any idea what is going on.

This is unfortunately not super compatible with the short format if there's stuff being printed during app boots however.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is undocumented application:info to see what is the current state, and why not all applications are booting correctly.

@ferd
Copy link
Collaborator

ferd commented Mar 10, 2021

Is silent / quiet / short / verbose the best way around this compared to the usual log levels we have? Or should the flag turn the boot message from info to debug? I don't feel strongly either way, but it feels like we're introducing various verbosity controls that could map reasonably well to existing controls. The short vs. verbose mode wouldn't fit that though.

@max-au
Copy link
Contributor Author

max-au commented Mar 10, 2021

To give some context about the issue I'm trying to solve: rebar3 shell may take some long time to boot all applications. However shell works asynchronously, and user can type things in the shell as soon as it is responsive.
" ===> Booted xxxxx" messages are disrupting shell input.

On one side, I like the idea of using log level to control this output (e.g. print "===> Booted" messages in debug verbosity). On the other, it'd be great to provide at least some feedback on the boot process. But in a way that does not disrupt shell interactions.

Maybe there is a way to somehow control TTY output and, for example, instead of logging apps that booted, display the name of the app that is being booted? I don't know whether it's possible to achieve this easily.

@max-au
Copy link
Contributor Author

max-au commented Mar 15, 2021

Another thought here, I wonder if it's possible to use TTY magic to print these "Booted" messages elsewhere, e.g. in the prompt.

@ferd
Copy link
Collaborator

ferd commented Mar 15, 2021

there are ways around that, though they wouldn't work with the old shell and might require manually sending instructions to unprint or scroll the terminal around. The real cool stuff sort of relies on curses-like APIs that are not very portable for escripts.

@max-au
Copy link
Contributor Author

max-au commented Mar 15, 2021

Then probably the smallest change is level parameter to shell, which can be set to info or debug, with info by default. It can switch output to be of a DEBUG level when desired.
I can change my PR do do exactly this.

@ferd
Copy link
Collaborator

ferd commented Mar 15, 2021

yeah that's likely the simplest basic one to run, I'd be fine with that. DEBUG output is getting more usable anyway and this is the kind of stuff that could make sense to push there.

This commit adds a parameter to `rebar.config` shell section:

    {shell, [
        {apps, [megaco, tools, runtime_tools]},
        {log, info | debug}
    ]}.

With 'info' (default), behaviour stays as before.
With 'debug', "===> Booted megaco" messages are printed with debug verbosity level,
and are available when rebar3 is run with DEBUG=1 environment variable.
@max-au max-au force-pushed the max-au/shell-boot-message branch from 0a8f34a to eb086dd Compare March 15, 2021 19:00
@ferd ferd merged commit ab5c342 into erlang:master Mar 16, 2021
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