Class Logger

  • All Implemented Interfaces:
    java.util.EventListener, org.eclipse.osgi.service.debug.DebugOptionsListener

    public final class Logger
    extends java.lang.Object
    implements org.eclipse.osgi.service.debug.DebugOptionsListener
    A simple logger class. Every method in this class is static, so they can be called from both class and instance methods. To use this class, write code like this:

     Logger.log("something has happened");
     Logger.log("counter is " + counter);
     
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void configure​(org.osgi.framework.BundleContext context)  
      static java.lang.String encode​(java.lang.String message)
      Encodes a String such that non-printable control characters are converted into user-readable escape sequences for logging.
      static boolean isLogEnabled()
      Checks if logging is enabled.
      boolean isOptionEnabled​(java.lang.String option)  
      static void log​(java.lang.String message)
      Logs the specified message.
      static void logException​(java.lang.Exception ex)
      Writes a stack trace for an exception to both Standard Error and to the log file.
      void optionsChanged​(org.eclipse.osgi.service.debug.DebugOptions options)  
      • Methods inherited from class java.lang.Object

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

      • TRACE_DEBUG_LOG_CHAR

        public static final java.lang.String TRACE_DEBUG_LOG_CHAR
        See Also:
        Constant Field Values
      • TRACE_DEBUG_LOG_VT100BACKEND

        public static final java.lang.String TRACE_DEBUG_LOG_VT100BACKEND
        See Also:
        Constant Field Values
    • Method Detail

      • configure

        public static void configure​(org.osgi.framework.BundleContext context)
      • encode

        public static final java.lang.String encode​(java.lang.String message)
        Encodes a String such that non-printable control characters are converted into user-readable escape sequences for logging.
        Parameters:
        message - String to encode
        Returns:
        encoded String
      • isLogEnabled

        public static final boolean isLogEnabled()
        Checks if logging is enabled.
        Returns:
        true if logging is enabled.
      • log

        public static final void log​(java.lang.String message)
        Logs the specified message. Do not append a newline to parameter message. This method does that for you.
        Parameters:
        message - A String containing the message to log.
      • logException

        public static final void logException​(java.lang.Exception ex)
        Writes a stack trace for an exception to both Standard Error and to the log file.
      • optionsChanged

        public void optionsChanged​(org.eclipse.osgi.service.debug.DebugOptions options)
        Specified by:
        optionsChanged in interface org.eclipse.osgi.service.debug.DebugOptionsListener
      • isOptionEnabled

        public boolean isOptionEnabled​(java.lang.String option)