Class XBLogger

  • Direct Known Subclasses:
    NullLogger

    public abstract class XBLogger
    extends Object
    A logger interface that strives to make it as easy as possible for developers to write log calls, while simultaneously making those calls as cheap as possible by performing lazy evaluation of the log message.

    • Method Detail

      • initialize

        public abstract void initialize​(String cat)
      • check

        public abstract boolean check​(int level)
        Check if a logger is enabled to log at the specified level This allows code to avoid building strings or evaluating functions in the arguments to log. An example:
         if (logger.check(XBLogger.INFO)) {
             logger.log(XBLogger.INFO, "Avoid concatenating " + " strings and evaluating " + functions());
         }
         
        Parameters:
        level - One of DEBUG, INFO, WARN, ERROR, FATAL
      • log

        public void log​(int level,
                        Object... objs)
        Log a message. Lazily appends Object parameters together. If the last parameter is a Throwable it is logged specially.
        Parameters:
        level - One of DEBUG, INFO, WARN, ERROR, FATAL
        objs - the objects to place in the message