Class EASyLoggerFactory

java.lang.Object
net.ssehub.easy.basics.logger.EASyLoggerFactory

public class EASyLoggerFactory extends Object
Factory 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 the containing package.
Author:
Sass
  • Field Details

    • 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:
    • LOGGING_LEVEL_PROPERTY

      private static final String LOGGING_LEVEL_PROPERTY
      See Also:
    • LOGGING_TRACE_PROPERTY

      private static final String LOGGING_TRACE_PROPERTY
      See Also:
    • TRACE

      private static final boolean TRACE
    • LOG_FILE_PATH

      private static final String LOG_FILE_PATH
      Specification to log into a specified file instead of logging into the console.
      See Also:
    • logger

      private ILogger logger
    • level

      private LoggingLevel level
  • Constructor Details

    • EASyLoggerFactory

      private EASyLoggerFactory()
      Singleton constructor for Logger.
  • Method Details

    • determineLevel

      private static LoggingLevel determineLevel(LoggingLevel defaultLevel)
      Checks whether a property was passed to the JVM for specifying a LoggingLevel. This method is part of the EASyLoggerFactory() (constructor).
      Parameters:
      defaultLevel - The default LoggingLevel which should be used, if no logging property was passed to the Java VM.
      Returns:
      Returns the specified LoggingLevel or LoggingLevel.WARN if no one was specified via a property.
    • getLogger

      public EASyLoggerFactory.EASyLogger getLogger(Class<?> clazz, 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 an ILogger. This ILogger will be used inside the getLogger(Class, String) method for creating concrete logger instances. Also all already created loggers will be updated automatically.
      Parameters:
      logger - The new ILogger which 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 the LoggingLevel that is used by the logger.
      Returns:
      The logging level that is set.
    • setLoggingLevel

      public void setLoggingLevel(LoggingLevel loggingLevel)
      Sets an LoggingLevel.
      Parameters:
      loggingLevel - The new LoggingLevel which shall be used to log.