diff --git a/base/src/main/java/de/staropensource/engine/base/logging/Logger.java b/base/src/main/java/de/staropensource/engine/base/logging/Logger.java index a428ea8..80a7e7d 100644 --- a/base/src/main/java/de/staropensource/engine/base/logging/Logger.java +++ b/base/src/main/java/de/staropensource/engine/base/logging/Logger.java @@ -61,6 +61,49 @@ public final class Logger { @Setter private static @NotNull LoggingAdapter loggingAdapter = new PlainLoggingAdapter(); + /** + * Contains if messages shall be + * sanitized during processing. + *
+ * Enabling this flag will prevent + * tag usage and with that formatting. + *
+ * Recommended to leave enabled. Only + * disable if you are developing a + * command line application. + * + * @since v1-alpha0 + * -- GETTER -- + * Returns if messages shall be + * sanitized during processing. + *
+ * Enabling this flag will prevent + * tag usage and with that formatting. + *
+ * Recommended to leave enabled. Only + * disable if you are developing a + * command line application. + * + * @return sanitize messages? + * @since v1-alpha0 + * -- SETTER -- + * Sets if messages shall be + * sanitized during processing. + *
+ * Enabling this flag will prevent + * tag usage and with that formatting. + *
+ * Recommended to leave enabled. Only + * disable if you are developing a + * command line application. + * + * @param sanitizeMessages sanitize messages? + * @since v1-alpha0 + */ + @Getter + @Setter + private static boolean sanitizeMessages = true; + /** * Creates and initializes an instance of this class * diff --git a/base/src/main/java/de/staropensource/engine/base/logging/backend/Processor.java b/base/src/main/java/de/staropensource/engine/base/logging/backend/Processor.java index 6dd540b..ee3343d 100644 --- a/base/src/main/java/de/staropensource/engine/base/logging/backend/Processor.java +++ b/base/src/main/java/de/staropensource/engine/base/logging/backend/Processor.java @@ -125,7 +125,7 @@ public final class Processor { if (isFeatureEnabled("level") && isFeatureEnabled("origin")) output.append(" "); if (isFeatureEnabled("origin")) { - issuerClass(output, level, issuer); + issuerClass(output, issuer); issuerModule(output, level, issuer); methodName(output, level, issuer); lineNumber(output, level, issuer); @@ -270,11 +270,10 @@ public final class Processor { * Adds the {@code issuer class} component. * * @param builder {@link StringBuilder} instance to append to - * @param level level of the log call * @param issuer {@link StackTraceElement} of the issuer * @since v1-alpha8 */ - private static void issuerClass(@NotNull StringBuilder builder, @NotNull LogLevel level, @NotNull StackTraceElement issuer) { + private static void issuerClass(@NotNull StringBuilder builder, @NotNull StackTraceElement issuer) { format(builder, "bold"); if (isFeatureEnabled("shortIssuerClass")) { @@ -351,12 +350,21 @@ public final class Processor { * @since v1-alpha8 */ private static void message(@NotNull StringBuilder builder, @NotNull String message) { - builder.append(sanitizeFormat(handlePlaceholders( + String finalizedMessage = handlePlaceholders( message.replace( "\n", - "\n" + " ".repeat(new EmptyShortcodeParser(builder.toString(), true).getClean().length()) + "\n" + " ".repeat( + new EmptyShortcodeParser(builder.toString(), true) + .getClean() + .length() + ) ) - ))); + ); + + if (Logger.isSanitizeMessages()) + finalizedMessage = sanitizeFormat(finalizedMessage); + + builder.append(finalizedMessage); } // -----> Utility methods