Class Logs


  • public final class Logs
    extends java.lang.Object
    Helper methods for improving usability of Log4j logger
    • Constructor Summary

      Constructors 
      Constructor Description
      Logs()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void debug​(org.apache.log4j.Logger log, java.util.function.Supplier logLineSupplier)
      Writes a log line with the DEBUG priority.
      static void debug​(org.apache.log4j.Logger log, java.util.function.Supplier logLineSupplier, java.lang.Throwable throwable)
      Writes a log line with the DEBUG priority.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Logs

        public Logs()
    • Method Detail

      • debug

        public static void debug​(org.apache.log4j.Logger log,
                                 java.util.function.Supplier logLineSupplier)
        Writes a log line with the DEBUG priority. Line might be provided by lambda expression, which is evaluated only when DEBUG is enabled on a given logger. It delegates to Category.debug(Object).

        This method allows you to write:

         
         		Logs.debug(LOG, () -> "Something " + calculateSomething() + " is wrong.");
         
         

        calculateSomething() will be called only when DEBUG is enabled.

        Parameters:
        log - logger to use
        logLineSupplier - log line supplier
      • debug

        public static void debug​(org.apache.log4j.Logger log,
                                 java.util.function.Supplier logLineSupplier,
                                 java.lang.Throwable throwable)
        Writes a log line with the DEBUG priority. Line might be provided by lambda expression, which is evaluated only when DEBUG is enabled on a given logger. It delegates to Category.debug(Object).

        This method allows you to write:

         
         		Logs.debug(LOG, () -> "Something " + calculateSomething() + " is wrong.", exception);
         
         

        calculateSomething() will be called only when DEBUG is enabled.

        Parameters:
        log - logger to use
        logLineSupplier - log line supplier
        throwable - throwable to log