Dev/251 refactor logging
Created by: KFilippopolitis
Refactored all logs.
- Disabled spring boot framework logs.
- Added 2 logs at every endpoint, when entering and returning, with useful information.
- Unified the logs output.
- Reworked the output in order for it to be visually consistent.
Merge request reports
Activity
Filter activity
Created by: ghost
DeepCode's analysis on #ac9030 found:
-
2 minor issues.
Top issues
Description Example fixes The expression inside info will be computed even if the log level is not high enough for the message to be logged. This will slow the application down in vain. Consider checking the log level before evaluating the expression. Occurrences: Example fixesDon't use string concatenation in java.lang.String.format, using string concatenation here defies the purpose of format. Occurrences: Example fixes View analysis in DeepCode’s Dashboard | Configure the bot-
11 12 public static void LogUserAction(String userName, String endpoint, String actionInfo) { 13 maxEndpointLen = (maxEndpointLen < userName.length() ? userName.length() : maxEndpointLen); 14 maxInfoLen = (maxInfoLen < endpoint.length() ? endpoint.length() : maxInfoLen); 15 String endpointSpacing = String.format("%" + (maxEndpointLen - userName.length() + 2) + "s", ""); 16 String infoSpacing = String.format("%" + (maxInfoLen - endpoint.length() + 2) + "s", ""); 17 LOGGER.info(" User -> " + userName 18 + endpointSpacing 19 + ", Endpoint -> " + endpoint 20 + infoSpacing 21 + ", Info -> " + actionInfo); 22 } 23 24 // Used from Threads because threads can't get userName. 25 public static void LogExperimentAction(String experimentName, String actionInfo) { 26 LOGGER.info(" Experiment -> " + experimentName 118 122 @ApiOperation(value = "Create an experiment", response = Experiment.class) 119 123 @RequestMapping(value = "/runAlgorithm", method = RequestMethod.POST) 120 124 public ResponseEntity<String> runExperiment(Authentication authentication, @RequestBody ExperimentExecutionDTO experimentExecutionDTO) { 121 UserActionLogging.LogUserAction(userInfo.getUser().getUsername(), "Run algorithm", "Running the algorithm..."); 125 User user = userInfo.getUser(); 126 // Get the type and name of algorithm 127 String algorithmType = experimentExecutionDTO.getAlgorithms().get(0).getType();
Please register or sign in to reply