Package migratedb.v1.core.api.logging
Class LogSystems
- java.lang.Object
-
- migratedb.v1.core.api.logging.LogSystems
-
public final class LogSystems extends Object
Pre-defined log system names and auto-detection.
-
-
Field Summary
Fields Modifier and Type Field Description static StringAPACHE_COMMONSorg.apache.commons.loggingsystem.static StringAUTO_DETECTAuto-detect based on environment.static StringCONSOLEAn alias that means the fallback logger will be used (this library has no opinion on what a "console" log should be).static StringJAVA_UTILjava.util.loggingsystem.static StringNONESuppresses all log messages.static StringSLF4Jorg.slf4jsystem.
-
Constructor Summary
Constructors Constructor Description LogSystems()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static LogSystemautoDetect(ClassLoader classLoader, @Nullable LogSystem fallback)Auto-detects the "best" available log system and returns an instance of it.static LogSystemcustom(String className, ClassLoader classLoader)Instantiates a class that implementsLogSystem.static LogSystemfromStrings(Set<String> logSystemNames, ClassLoader classLoader, @Nullable LogSystem fallback)Creates a log system that forwards logging calls to all log system names inlogSystemNames.
-
-
-
Field Detail
-
APACHE_COMMONS
public static final String APACHE_COMMONS
org.apache.commons.loggingsystem.- See Also:
- Constant Field Values
-
AUTO_DETECT
public static final String AUTO_DETECT
Auto-detect based on environment. SeeautoDetect(ClassLoader, LogSystem).- See Also:
- Constant Field Values
-
JAVA_UTIL
public static final String JAVA_UTIL
java.util.loggingsystem.- See Also:
- Constant Field Values
-
SLF4J
public static final String SLF4J
org.slf4jsystem.- See Also:
- Constant Field Values
-
CONSOLE
public static final String CONSOLE
An alias that means the fallback logger will be used (this library has no opinion on what a "console" log should be).- See Also:
- Constant Field Values
-
NONE
public static final String NONE
Suppresses all log messages.- See Also:
- Constant Field Values
-
-
Method Detail
-
fromStrings
public static LogSystem fromStrings(Set<String> logSystemNames, ClassLoader classLoader, @Nullable LogSystem fallback)
Creates a log system that forwards logging calls to all log system names inlogSystemNames. Each log system name must either be one of the string constants in this class or the fully qualified name of a class that implementsLogSystemand has a public no-arg constructor.- Parameters:
logSystemNames- The log system names to parseclassLoader- Used to instantiate classes by namefallback- Used forAUTO_DETECTandCONSOLE(the latter being a direct alias for it)- Returns:
- Log system that delegates to all log systems identified by
logSystemNames.
-
custom
public static LogSystem custom(String className, ClassLoader classLoader)
Instantiates a class that implementsLogSystem.- Parameters:
className- Fully qualified name of class to instantiate. Class must have a public no-arg constructor.classLoader- Class loader to use.- Returns:
- The custom log system.
-
autoDetect
public static LogSystem autoDetect(ClassLoader classLoader, @Nullable LogSystem fallback)
Auto-detects the "best" available log system and returns an instance of it. The order of precedence is:- If one of the supported logging libraries is found via
classLoader, use it. - If
fallbackis non-null, use that. - Use
java.util.logging.
- Parameters:
classLoader- Used to check for the presence of supported logging libraries.fallback- Log system to use overjava.util.logging- Returns:
- Auto-detected log system.
- If one of the supported logging libraries is found via
-
-