You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Component to be refactored
Replace calls to System.out.println to use JUL logging instead.
Purpose of refactoring
Using Java Util Logging is more maintainable than using System.out.println for several reasons. Firstly, Java Util Logging provides different logging levels (SEVERE, WARNING, INFO, etc.), which allows for more granular control over what information is logged and when. This is not possible with System.out.println, which outputs everything regardless of its importance. Secondly, Java Util Logging supports output to different targets, not just the console, but also file systems, sockets, etc., and can be easily configured to change the output target. Thirdly, Java Util Logging supports formatting of log messages, which can make the logs easier to read and parse. Lastly, using a logging framework like Java Util Logging can improve performance, as it can be configured to log messages asynchronously. On the other hand, using System.out.println can slow down an application because it's a synchronous operation.
Proposed method SonarCloud has identified quite a few calls that need to be rerouted . They should all be replaced, though the effort might be too high to do at once so this might be accomplished in several efforts or when surrounding code is updated.
Additional context
As a stopgap HEC has been using Flogger (Google's fluent logger API) to reroute all System.out calls to JUL and whenever code lines are updated surrounding the System.out code, they are replaced with JUL calls.
The text was updated successfully, but these errors were encountered:
Probably good to get feedback from @opendcs/opendcs-core-devs
A lot of the libraries we use (I plan to excise the hec libraries for various reasons over time unless absolutely required) already use slf4j as the facade anyways.
Good point, there are about the same number of references in the codebase to JUL as there are System.out (~>300 total), so double the effort to switch everything to slf4j.
Component to be refactored
Replace calls to System.out.println to use JUL logging instead.
Purpose of refactoring
Using Java Util Logging is more maintainable than using
System.out.println
for several reasons. Firstly, Java Util Logging provides different logging levels (SEVERE, WARNING, INFO, etc.), which allows for more granular control over what information is logged and when. This is not possible withSystem.out.println
, which outputs everything regardless of its importance. Secondly, Java Util Logging supports output to different targets, not just the console, but also file systems, sockets, etc., and can be easily configured to change the output target. Thirdly, Java Util Logging supports formatting of log messages, which can make the logs easier to read and parse. Lastly, using a logging framework like Java Util Logging can improve performance, as it can be configured to log messages asynchronously. On the other hand, usingSystem.out.println
can slow down an application because it's a synchronous operation.Proposed method
SonarCloud has identified quite a few calls that need to be rerouted . They should all be replaced, though the effort might be too high to do at once so this might be accomplished in several efforts or when surrounding code is updated.
Additional context
As a stopgap HEC has been using Flogger (Google's fluent logger API) to reroute all
System.out
calls to JUL and whenever code lines are updated surrounding theSystem.out
code, they are replaced with JUL calls.The text was updated successfully, but these errors were encountered: