Package net.ssehub.easy.basics.logger
Class EASyLoggerFactory
- java.lang.Object
-
- net.ssehub.easy.basics.logger.EASyLoggerFactory
-
public class EASyLoggerFactory extends java.lang.ObjectFactory for the current logger. The current logger is encapsulated in EASyLogger to provide simple access. For an example of the usage of this class see thecontaining package.- Author:
- Sass
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classEASyLoggerFactory.EASyLoggerLogger instance for logging in plug-ins of the EASy-Producer.
-
Field Summary
Fields Modifier and Type Field Description static booleanDEBUGThis constant value should be set to: false: For a release. true: For development.static EASyLoggerFactoryINSTANCEprivate LoggingLevellevelprivate static java.lang.StringLOG_FILE_PATHSpecification to log into a specified file instead of logging into the console.private ILoggerloggerprivate static java.lang.StringLOGGING_LEVEL_PROPERTY
-
Constructor Summary
Constructors Modifier Constructor Description privateEASyLoggerFactory()Singleton constructor for Logger.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static LoggingLeveldetermineLevel(LoggingLevel defaultLevel)Checks whether a property was passed to the JVM for specifying aLoggingLevel.EASyLoggerFactory.EASyLoggergetLogger(java.lang.Class<?> clazz, java.lang.String bundleName)Returns a logger instance for logging informations, warnings, and errors in a concrete class.LoggingLevelgetLoggingLevel()Returns theLoggingLevelthat is used by the logger.ILoggersetLogger(ILogger logger)Sets anILogger.voidsetLoggingLevel(LoggingLevel loggingLevel)Sets anLoggingLevel.
-
-
-
Field Detail
-
INSTANCE
public static final EASyLoggerFactory INSTANCE
-
DEBUG
public static final boolean DEBUG
This constant value should be set to:- false: For a release.
- true: For development.
- See Also:
- Constant Field Values
-
LOGGING_LEVEL_PROPERTY
private static final java.lang.String LOGGING_LEVEL_PROPERTY
- See Also:
- Constant Field Values
-
LOG_FILE_PATH
private static final java.lang.String LOG_FILE_PATH
Specification to log into a specified file instead of logging into the console.- See Also:
- Constant Field Values
-
logger
private ILogger logger
-
level
private LoggingLevel level
-
-
Method Detail
-
determineLevel
private static LoggingLevel determineLevel(LoggingLevel defaultLevel)
Checks whether a property was passed to the JVM for specifying aLoggingLevel. This method is part of theEASyLoggerFactory()(constructor).- Parameters:
defaultLevel- The defaultLoggingLevelwhich should be used, if no logging property was passed to the Java VM.- Returns:
- Returns the specified
LoggingLevelorLoggingLevel.WARNif no one was specified via a property.
-
getLogger
public EASyLoggerFactory.EASyLogger getLogger(java.lang.Class<?> clazz, java.lang.String bundleName)
Returns a logger instance for logging informations, warnings, and errors in a concrete class. This logger instance should not be passed to other classes.- Parameters:
clazz- The class to log.bundleName- The name of the plug-in containing the logged class (can be null).- Returns:
- ILogger A logger instance for this specified class and plug-in.
-
setLogger
public ILogger setLogger(ILogger logger)
Sets anILogger. ThisILoggerwill be used inside thegetLogger(Class, String)method for creating concrete logger instances. Also all already created loggers will be updated automatically.- Parameters:
logger- The newILoggerwhich shall be used to log all info, warnings, and errors. Must not be null.- Returns:
- the active logger before this operation
-
getLoggingLevel
public LoggingLevel getLoggingLevel()
Returns theLoggingLevelthat is used by the logger.- Returns:
- The logging level that is set.
-
setLoggingLevel
public void setLoggingLevel(LoggingLevel loggingLevel)
Sets anLoggingLevel.- Parameters:
loggingLevel- The newLoggingLevelwhich shall be used to log.
-
-