mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 10:54:51 +00:00
Formatting
This commit is contained in:
@@ -8,16 +8,13 @@ import org.apache.logging.log4j.core.config.LoggerConfig;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility class for configuring logging levels dynamically at runtime using Log4j 2.
|
* Utility class for configuring logging levels dynamically at runtime using Log4j 2.
|
||||||
* <p>
|
*
|
||||||
* Provides methods to enable or disable logs globally or per class, with support for
|
* <p>Provides methods to enable or disable logs globally or per class, with support for specifying
|
||||||
* specifying log levels either via {@link Level} enums or string names.
|
* log levels either via {@link Level} enums or string names.
|
||||||
* </p>
|
|
||||||
*/
|
*/
|
||||||
public final class Logging {
|
public final class Logging {
|
||||||
|
|
||||||
/**
|
/** Disables all logging globally by setting the root logger level to {@link Level#OFF}. */
|
||||||
* Disables all logging globally by setting the root logger level to {@link Level#OFF}.
|
|
||||||
*/
|
|
||||||
public static void disableAllLogs() {
|
public static void disableAllLogs() {
|
||||||
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
||||||
Configuration config = ctx.getConfiguration();
|
Configuration config = ctx.getConfiguration();
|
||||||
@@ -26,9 +23,7 @@ public final class Logging {
|
|||||||
ctx.updateLoggers();
|
ctx.updateLoggers();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Enables all logging globally by setting the root logger level to {@link Level#ALL}. */
|
||||||
* Enables all logging globally by setting the root logger level to {@link Level#ALL}.
|
|
||||||
*/
|
|
||||||
public static void enableAllLogs() {
|
public static void enableAllLogs() {
|
||||||
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
||||||
Configuration config = ctx.getConfiguration();
|
Configuration config = ctx.getConfiguration();
|
||||||
@@ -83,7 +78,7 @@ public final class Logging {
|
|||||||
* Disables logs for a specific class.
|
* Disables logs for a specific class.
|
||||||
*
|
*
|
||||||
* @param class_ the class for which logs should be disabled
|
* @param class_ the class for which logs should be disabled
|
||||||
* @param <T> type of the class
|
* @param <T> type of the class
|
||||||
*/
|
*/
|
||||||
public static <T> void disableLogsForClass(Class<T> class_) {
|
public static <T> void disableLogsForClass(Class<T> class_) {
|
||||||
disableLogsForClassInternal(class_.getName());
|
disableLogsForClassInternal(class_.getName());
|
||||||
@@ -104,7 +99,7 @@ public final class Logging {
|
|||||||
* Internal helper to enable logs for a specific class at a specific level.
|
* Internal helper to enable logs for a specific class at a specific level.
|
||||||
*
|
*
|
||||||
* @param className fully-qualified class name
|
* @param className fully-qualified class name
|
||||||
* @param level logging level to set
|
* @param level logging level to set
|
||||||
*/
|
*/
|
||||||
private static void enableLogsForClassInternal(String className, Level level) {
|
private static void enableLogsForClassInternal(String className, Level level) {
|
||||||
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
||||||
@@ -122,9 +117,9 @@ public final class Logging {
|
|||||||
/**
|
/**
|
||||||
* Enables logging for a class at a specific level.
|
* Enables logging for a class at a specific level.
|
||||||
*
|
*
|
||||||
* @param class_ class to configure
|
* @param class_ class to configure
|
||||||
* @param levelToLog the logging level to set
|
* @param levelToLog the logging level to set
|
||||||
* @param <T> type of the class
|
* @param <T> type of the class
|
||||||
*/
|
*/
|
||||||
public static <T> void enableLogsForClass(Class<T> class_, Level levelToLog) {
|
public static <T> void enableLogsForClass(Class<T> class_, Level levelToLog) {
|
||||||
enableLogsForClassInternal(class_.getName(), levelToLog);
|
enableLogsForClassInternal(class_.getName(), levelToLog);
|
||||||
@@ -133,8 +128,8 @@ public final class Logging {
|
|||||||
/**
|
/**
|
||||||
* Enables logging for a class specified by name at a specific level, if the class exists.
|
* Enables logging for a class specified by name at a specific level, if the class exists.
|
||||||
*
|
*
|
||||||
* @param className fully-qualified class name
|
* @param className fully-qualified class name
|
||||||
* @param levelToLog the logging level to set
|
* @param levelToLog the logging level to set
|
||||||
*/
|
*/
|
||||||
public static void enableLogsForClass(String className, Level levelToLog) {
|
public static void enableLogsForClass(String className, Level levelToLog) {
|
||||||
if (verifyStringIsActualClass(className)) {
|
if (verifyStringIsActualClass(className)) {
|
||||||
@@ -145,8 +140,8 @@ public final class Logging {
|
|||||||
/**
|
/**
|
||||||
* Enables logging for a class specified by name at a specific level using a string.
|
* Enables logging for a class specified by name at a specific level using a string.
|
||||||
*
|
*
|
||||||
* @param className fully-qualified class name
|
* @param className fully-qualified class name
|
||||||
* @param levelToLog name of the logging level (e.g., "DEBUG", "INFO")
|
* @param levelToLog name of the logging level (e.g., "DEBUG", "INFO")
|
||||||
*/
|
*/
|
||||||
public static void enableLogsForClass(String className, String levelToLog) {
|
public static void enableLogsForClass(String className, String levelToLog) {
|
||||||
Level level = Level.valueOf(levelToLog.trim().toUpperCase());
|
Level level = Level.valueOf(levelToLog.trim().toUpperCase());
|
||||||
|
|||||||
@@ -17,5 +17,4 @@ public class Player {
|
|||||||
public char getSymbol() {
|
public char getSymbol() {
|
||||||
return this.symbol;
|
return this.symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,4 @@ class PlayerTest {
|
|||||||
assertEquals('X', playerA.getSymbol());
|
assertEquals('X', playerA.getSymbol());
|
||||||
assertEquals('O', playerB.getSymbol());
|
assertEquals('O', playerB.getSymbol());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user