Skip to content

Commit

Permalink
Fixing sonarcloud recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
softwaremagico committed Sep 13, 2024
1 parent 3e024d2 commit 0765271
Showing 1 changed file with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ public static void warning(Logger logger, String messageTemplate, Object... argu
* @param arguments parameters to fill up the template
*/
public static void warning(Logger logger, String className, String messageTemplate, Object... arguments) {
for (int i = 0; i < arguments.length; i++) {
if (arguments[i] != null) {
arguments[i] = arguments[i].toString().replaceAll("[\n\r\t]", "_");
if (logger.isWarnEnabled()) {
for (int i = 0; i < arguments.length; i++) {
if (arguments[i] != null) {
arguments[i] = arguments[i].toString().replaceAll("[\n\r\t]", "_");
}
}
final String templateWithClass = className + ": " + messageTemplate;
logger.warn(templateWithClass.replaceAll("[\n\r]", "_"), arguments);
}
final String templateWithClass = className + ": " + messageTemplate;
logger.warn(templateWithClass.replaceAll("[\n\r]", "_"), arguments);
}

/**
Expand All @@ -71,12 +73,14 @@ public static void warning(Logger logger, String className, String messageTempla
* @param arguments parameters to fill up the template
*/
public static void info(Logger logger, String messageTemplate, Object... arguments) {
for (int i = 0; i < arguments.length; i++) {
if (arguments[i] != null) {
arguments[i] = arguments[i].toString().replaceAll("[\n\r\t]", "_");
if (logger.isInfoEnabled()) {
for (int i = 0; i < arguments.length; i++) {
if (arguments[i] != null) {
arguments[i] = arguments[i].toString().replaceAll("[\n\r\t]", "_");
}
}
logger.info(messageTemplate.replaceAll("[\n\r]", "_"), arguments);
}
logger.info(messageTemplate, arguments);
}

/**
Expand Down Expand Up @@ -135,12 +139,14 @@ public static void debug(Logger logger, String className, String messageTemplate
* @param arguments parameters to fill up the template
*/
protected static void severe(Logger logger, String messageTemplate, Object... arguments) {
for (int i = 0; i < arguments.length; i++) {
if (arguments[i] != null) {
arguments[i] = arguments[i].toString().replaceAll("[\n\r\t]", "_");
if (logger.isErrorEnabled()) {
for (int i = 0; i < arguments.length; i++) {
if (arguments[i] != null) {
arguments[i] = arguments[i].toString().replaceAll("[\n\r\t]", "_");
}
}
logger.error(messageTemplate.replaceAll("[\n\r]", "_"), arguments);
}
logger.error(messageTemplate, arguments);
}

/**
Expand Down

0 comments on commit 0765271

Please sign in to comment.