feat: only print container logs with --focus
#1945
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a new
--focus
(-f
) flag, which, when enabled, will suppress all logs except those emitted by the processes inside the running container.Doing so, reduces this:
To this:
The two differences are:
WARN
or above.For those who really only want the process logs without any annotations, you can add
--json
and then format the output usingjq
etc, e.g.:The implementation itself works, but isn't as elegant as I would like because I didn't want to introduce any backward breaking changes.
I think, ideally, with two separate loggers (one for the process messages, the other for messages from act itself), there would be flags to control the log level of each individual logger, and do away with
--quiet
,--focus
, and--verbose
.But, the current implementation works for me and doesn't introduce any backward breaking changes, so I figured I'd push this up, either for you to modify, or take as is.
One other alternative that I only thought of as I was writing this PR description, is to introduce a new field on the JSON-based log output, to distinguish between process and act logs. That way, we could again use
jq
to filter out the logs we don't want. The downside is we'd lose the pretty printing niceties, so it's a trade-off of supporting this in the utility itself, or giving people the hooks to do it themselves outside the process.Edit: one more thing I forgot to mention β I didn't add any tests yet. I'm uncertain if/where logging output is tested, so feel free to either add it yourself, or give me some pointers, so I can see if I can find some additional time to add them.