'println' call can be replaced with a logpoint
Logpoints is a debugger feature that enables printing expressions (kotlin.io.println) to the standard output without changing the source code. It has a few advantages over common println in source code:
Logpoints can be added, modified, and removed during execution, no need to hot-reload;
As a consequence, they can be used in library code, which cannot be manually changed;
Logpoints may not even compile, it wouldn't affect the program execution;
There is no risk of leaking printing calls into production, as logpoints are not part of the source code.
The inspection only works if there's an executable line after the println call, and this line is not a loop statement. This restriction is made because breakpoints work differently at these places, and the replacement is not equivalent.
NOTE: Logpoints only work in Debug mode. In Run, Run with Coverage, Profile modes, logpoint expressions won't appear in the output.
Locating this inspection
- By ID
Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.
KotlinPrintToLogpoint- Via Settings dialog
Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.
Inspection ID: KotlinPrintToLogpoint
Suppressing Inspection
You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:
More detailed instructions as well as other ways and options that you have can be found in the product documentation:
Inspection Details | |
|---|---|
By default bundled with: |