Class SolaLogger

java.lang.Object
technology.sola.logging.SolaLogger
Direct Known Subclasses:
JavaSolaLogger

@NullMarked public abstract class SolaLogger extends Object
SolaLogger instances are used to log messages to the console and/or files. SolaLogger must be configured via configure(SolaLogLevel, SolaLoggerFactory) before instances can be created via of(Class). The log level of all logger instances will be the same based on how SolaLogger was configured.
  • Constructor Details

    • SolaLogger

      public SolaLogger()
  • Method Details

    • configure

      public static void configure(SolaLogLevel level, SolaLoggerFactory solaLoggerFactory)
      Configures all resulting SolaLoggers to have desired SolaLogLevel and to be created via desired SolaLoggerFactory.
      Parameters:
      level - the log level for all logger instances
      solaLoggerFactory - the factory used to create new logger instances
    • of

      public static SolaLogger of(Class<?> clazz)
      Utilizes the configured SolaLoggerFactory to create a new SolaLogger instance for desired class.
      Parameters:
      clazz - the class to create a logger for
      Returns:
      new logger instance
    • of

      public static SolaLogger of(Class<?> clazz, String logFile)
      Utilizes the configured SolaLoggerFactory to create a new SolaLogger instance for desired class. If the SolaLoggerFactory creates instances that support writing to a file then the provided log file will be used to write to.
      Parameters:
      clazz - the class to create a logger for
      logFile - the log file to write to
      Returns:
      new logger instance
    • info

      public void info(String message)
      Logs a message at SolaLogLevel.INFO.
      Parameters:
      message - the message to log
    • info

      public void info(String message, Object... params)
      Logs a message at SolaLogLevel.INFO. This uses String.format(String, Object...) to format the log message.
      Parameters:
      message - the message to log
      params - the additional params for the log message
    • warning

      public void warning(String message)
      Logs a message at SolaLogLevel.WARNING.
      Parameters:
      message - the message to log
    • warning

      public void warning(String message, Object... params)
      Logs a message at SolaLogLevel.WARNING. This uses String.format(String, Object...) to format the log message.
      Parameters:
      message - the message to log
      params - the additional params for the log message
    • error

      public void error(String message)
      Logs a message at SolaLogLevel.ERROR.
      Parameters:
      message - the message to log
    • error

      public void error(String message, Throwable throwable)
      Logs a message at SolaLogLevel.ERROR. Additionally, the passed Throwable will be logged.
      Parameters:
      message - the message to log
      throwable - the exception that should be logged
    • error

      public void error(String message, Throwable throwable, Object... params)
      Logs a message at SolaLogLevel.ERROR. This uses String.format(String, Object...) to format the log message. Additionally, the passed Throwable will be logged.
      Parameters:
      message - the message to log
      throwable - the exception that should be logged
      params - the additional params for the log message
    • log

      protected abstract void log(SolaLogLevel level, String message, @Nullable Throwable throwable, Object... params)
      Logs a message at desired SolaLogLevel. This uses String.format(String, Object...) to format the log message. Additionally, the passed Throwable will be logged if provided.
      Parameters:
      level - the SolaLogLevel to log at
      message - the message to log
      throwable - the exception that should be logged
      params - the additional params for the log message