Kotlin / kotlinx-kover

Apache License 2.0
1.25k stars 46 forks source link

Changed log level for print coverage task #563

Closed shanshin closed 1 month ago

shanshin commented 2 months ago

At the moment, the coverage was printed with the lifecycle level. However, if user limit the logs to the --warn level, the coverage stops printing. Now coverage is printed with the quite level, thanks to this it is printed even with the limitations of --warn and --quiet.

Fixes #557

sandwwraith commented 2 months ago

Documentation says that "-q, --quiet: Log errors only." I wouldn't expect to see coverage logs at this level unless low coverage is reason for failing the build. IMO, if user specifies --quiet, they expect log in the destination file only, not in the output.

shanshin commented 2 months ago

Documentation says that "-q, --quiet: Log errors only." I wouldn't expect to see coverage logs at this level unless low coverage is reason for failing the build. IMO, if user specifies --quiet, they expect log in the destination file only, not in the output.

According Gradle docs quiet level is a important message which should always be printed.

At the same time, if you do not need coverage logs, then you do not need to call the koverLog task. Task koverLog is intended only for printing the coverage to the output, users don't even know about the existence of the file - it's an implementation detail.

mgroth0 commented 2 months ago

@sandwwraith , I created https://github.com/Kotlin/kotlinx-kover/issues/557 because I expect the koverPrintCoverage task to have the same kind of behavior as tasks; it is meant to be used as a manually triggered task for quickly seeing some information, not to be part of a regular build.

The gradle tasks task is like this. It is an optional, manually triggered task that prints useful information when want to see it. It still prints, even if log level is set to warn and --quiet is used.

The problem is that as things currently stand, I have to temporarily increase my log level to lifecycle or higher just to quickly see the info in koverPrintCoverage. This is a small inconvenience and of course I could also create my own custom task instead if I wanted to keep my log level on warn. But the biggest problem here is that when I do not see any output from koverPrintCoverage, I have no way to know why there is no output. Before I created this issue I had to debug and problem solve just to figure out why koverPrintCoverage was not printing anything, and wasted time in the process just to end up realizing I needed to change my log level. That's why I think this change should be made, because I think most people will assume that if a task has print in the name it will print always regardless of log level (like the tasks task), and if nothing is printed people will get confused.

sandwwraith commented 1 month ago

@mgroth0 Thanks for detailed explanation!