Package com.iizix

Class ILog

java.lang.Object
com.iizix.ILog

public class ILog extends Object
Class handling logging for a module in the system, also maybe with specific settings in regards to log levels and log redirectors.

The Loggers class handles the available and registered loggers on a thread or thread group basis, or an instance of a class that can hold the particular instance data.

Optional arguments are placed in order where the formatting string contains open/close braces as "{}". If there are missing braces, each additional argument is placed on a numbered line below, indented with " - ", resulting in e.g. " - 1 = argument-as-string".

The following arguments are converted using "deep-toString" meaning their contents and subcontents are deep-toString'eg if possible, otherwise just as "toString()".

  • null: "null".
  • Array of primitives: the entire array is expanded.
  • com.iizix.prop.StringMapProp or java.util.Map: lists all the contents on new lines as " - key = value".
  • Throwable: expanded throwable with stack trace, including potential ignored exception and cause.
Author:
Christopher Mindus
  • Field Details Link icon

  • Constructor Details Link icon

    • ILog Link icon

      public ILog(Class<?> originator)
      Creates an instance of the logger for an originator.
      Parameters:
      originator - originating class
    • ILog Link icon

      public ILog(String name)
      Creates an instance of a named logger.
      Parameters:
      name - The name of the logger.
  • Method Details Link icon

    • mapJSLogLevelToJava Link icon

      public static int mapJSLogLevelToJava(int level)
      Maps the JavaScript log levels [0='DEBUG',1='INFO',2='WARN',3='ERROR',4='FATAL',5='NONE',6='ALWAYS'] to Java. NONE and "n/a" maps to FINE.
      Parameters:
      level - The JavaScript log level.
      Returns:
      The Java log level.
    • getLogLevel Link icon

      public static int getLogLevel()
      Gets the currently configured log level.
      Returns:
      The current log level (1-7) SEVERE-FINEST.
    • setLogLevel Link icon

      public static boolean setLogLevel(int newLevel)
      Changes the logger log level.
      Parameters:
      newLevel - the new log level (1-7) SEVERE-FINEST.
      Returns:
      true if any setting changed, false if same values were present.
    • isLogged Link icon

      public static boolean isLogged(int level)
      Checks if the event would normally be logged. This call is typically used to avoid multiple log outputs one after another or if the message to log is very complex to compute in terms of String concatenation and building.

      The return value might be true but the event still not logged later on. This might be the case if some special filtering is applied in order to see just the log of e.g. a particular client, application or thread.

      Parameters:
      level - The log level.
      Returns:
      true if the event is normally logged, false otherwise.
    • getShortenedClassName Link icon

      public static String getShortenedClassName(Class<?> clazz)
      Gets the shortened name of a class.
      Parameters:
      clazz - The class, or null for "system".
      Returns:
      The short form of the class name, or system if clazz is null.
      See Also:
    • getShortenedClassName Link icon

      public static String getShortenedClassName(String cn)
      Gets the shortened name of a class.

      The following list shows the names beginning with a prefix and what the replacement is:

      • "com.iizix." -> "ci."
      • "com.iizix.prop." -> "cip."
      • "com.iizix.server." -> "cis."
      • "com.iizigo." -> "cI."
      • "org.eclipse.jetty." -> "oej."
      • "org.eclipse.jetty.server." -> "oejs."
      Parameters:
      cn - The class name.
      Returns:
      The short form of the class name (if any short for exists), or "system" if the cn parameter was null.
    • entering Link icon

      public void entering(Object... params)
      Call to indicate that a method is entered. If log level is set to FINER or less, this will be logged. The method name is fetched implicitly. However, this assumes that the containing class has the following static member: private static ILog log = new ILog(ClassName.class);
      Parameters:
      params - Optional parameters
    • exiting Link icon

      public void exiting()
      Call to indicate that a method is exited. If log level is set to FINER or less, this will be logged.

      The method name is fetched implicitly from the call stack.. However, this assumes that the containing class has the following static member: private static ILog log = new ILog(ClassName.class);

    • entering Link icon

      public static void entering(Class<?> originator, String method)
      Call to indicate that a method is entered. If log level is set to FINER or less, this will be logged.
      Parameters:
      originator - The originator class
      method - The method name
    • entering Link icon

      public static void entering(Object originator, String method)
      Call to indicate that a method is entered. If log level is set to FINER or less, this will be logged.

      The originator parameter will be used to look up the class name from the instance.

      Parameters:
      originator - The originator instance
      method - The method name
    • entering Link icon

      public static void entering(String originator, String method)
      Call to indicate that a method is entered. If log level is set to FINER or less, this will be logged.

      The originator parameter will be used to look up the class name from the instance.

      Parameters:
      originator - The originator instance
      method - The method name
    • entering Link icon

      public static void entering(Class<?> originator, String method, Object param1)
      Call to indicate that a method is entered. If log level is set to FINER or less, this will be logged.
      Parameters:
      originator - the containing class
      method - explicit method name
      param1 - the fist parameter
    • entering Link icon

      public static void entering(Class<?> originator, String method, Object... params)
      Call to indicate that a method is entered. If log level is set to FINER or less, this will be logged.
      Parameters:
      originator - the containing class
      method - explicit method name
      params - list of parameters
    • exiting Link icon

      public static void exiting(Class<?> originator, String method)
      Call to indicate that a method is exited. If log level is set to FINER or less, this will be logged.
      Parameters:
      originator - the containing class
      method - explicit method name
    • exiting Link icon

      public static void exiting(String originator, String method)
      Call to indicate that a method is exited. If log level is set to FINER or less, this will be logged.
      Parameters:
      originator - the origin
      method - explicit method name
    • exiting Link icon

      public static void exiting(Class<?> originator, String method, Object result)
      Call to indicate that a method is exited with a return value. If log level is set to FINER or less, this will be logged.
      Parameters:
      originator - the containing class
      method - explicit method name
      result - the result
    • exiting Link icon

      public static void exiting(String originator, String method, Object result)
      Call to indicate that a method is exited with a return value. If log level is set to FINER or less, this will be logged.
      Parameters:
      originator - the origin
      method - explicit method name
      result - the result
    • format Link icon

      public static String format(Object... params)
      Formats an array of parameters.
      Parameters:
      params - List of parameters, or null for none.
      Returns:
      The formatted string of parameters using Utilities.toString(Object).
    • FINEST Link icon

      public static void FINEST(String msg)
      Outputs a finest log event.
      Parameters:
      msg - message to log
    • finest Link icon

      public void finest(String msg)
      Outputs a finest log event.
      Parameters:
      msg - message to log
    • FINEST Link icon

      public static void FINEST(String msg, Object param1)
      Outputs a finest log event.
      Parameters:
      msg - message to log
      param1 - first parameter
    • finest Link icon

      public void finest(String msg, Object param1)
      Outputs a finest log event.
      Parameters:
      msg - message to log
      param1 - first parameter
    • FINEST Link icon

      public static void FINEST(String msg, Object... params)
      Outputs a finest log event.
      Parameters:
      msg - message to log
      params - parameters
    • finest Link icon

      public void finest(String msg, Object... params)
      Outputs a finest log event.
      Parameters:
      msg - message to log
      params - parameters
    • FINEST Link icon

      public static void FINEST(String msg, Throwable thrown)
      Outputs a finest log event.
      Parameters:
      msg - message to log
      thrown - thrown exception
    • finest Link icon

      public void finest(String msg, Throwable thrown)
      Outputs a finest log event.
      Parameters:
      msg - message to log
      thrown - thrown exception
    • FINEST Link icon

      public static void FINEST(Class<?> originator, String msg)
      Outputs a finest log event.
      Parameters:
      originator - originating class
      msg - message
    • FINEST Link icon

      public static void FINEST(Class<?> originator, String msg, Object param1)
      Outputs a finest log event.
      Parameters:
      originator - originating class
      msg - message
      param1 - first parameter
    • FINEST Link icon

      public static void FINEST(Class<?> originator, String msg, Object... params)
      Outputs a finest log event.
      Parameters:
      originator - originating class
      msg - message
      params - parameters
    • FINEST Link icon

      public static void FINEST(Class<?> originator, String msg, Throwable thrown)
      Outputs a finest log event.
      Parameters:
      originator - originating class
      msg - message
      thrown - thrown Exception
    • FINER Link icon

      public static void FINER(String msg)
      Outputs a finer log event.
      Parameters:
      msg - message to log
    • finer Link icon

      public void finer(String msg)
      Outputs a finer log event.
      Parameters:
      msg - message to log
    • FINER Link icon

      public static void FINER(String msg, Object param1)
      Outputs a finer log event.
      Parameters:
      msg - message to log
      param1 - first parameter
    • finer Link icon

      public void finer(String msg, Object param1)
      Outputs a finer log event.
      Parameters:
      msg - message to log
      param1 - first parameter
    • FINER Link icon

      public static void FINER(String msg, Object... params)
      Outputs a finer log event.
      Parameters:
      msg - message to log
      params - parameters
    • finer Link icon

      public void finer(String msg, Object... params)
      Outputs a finer log event.
      Parameters:
      msg - message to log
      params - parameters
    • FINER Link icon

      public static void FINER(String msg, Throwable thrown)
      Outputs a finer log event.
      Parameters:
      msg - message to log
      thrown - thrown exception
    • finer Link icon

      public void finer(String msg, Throwable thrown)
      Outputs a finer log event.
      Parameters:
      msg - message to log
      thrown - thrown exception
    • FINER Link icon

      public static void FINER(Class<?> originator, String msg)
      Outputs a finer log event.
      Parameters:
      originator - originating class
      msg - message
    • FINER Link icon

      public static void FINER(Class<?> originator, String msg, Object param1)
      Outputs a finer log event.
      Parameters:
      originator - originating class
      msg - message
      param1 - first parameter
    • FINER Link icon

      public static void FINER(Class<?> originator, String msg, Object... params)
      Outputs a finer log event.
      Parameters:
      originator - originating class
      msg - message
      params - parameters
    • FINER Link icon

      public static void FINER(Class<?> originator, String msg, Throwable thrown)
      Outputs a finer log event.
      Parameters:
      originator - originating class
      msg - message
      thrown - thrown Exception
    • FINE Link icon

      public static void FINE(String msg)
      Outputs a fine log event.
      Parameters:
      msg - message to log
    • fine Link icon

      public void fine(String msg)
      Outputs a fine log event.
      Parameters:
      msg - message to log
    • FINE Link icon

      public static void FINE(String msg, Object param1)
      Outputs a fine log event.
      Parameters:
      msg - message to log
      param1 - first parameter
    • fine Link icon

      public void fine(String msg, Object param1)
      Outputs a fine log event.
      Parameters:
      msg - message to log
      param1 - first parameter
    • FINE Link icon

      public static void FINE(String msg, Object... params)
      Outputs a fine log event.
      Parameters:
      msg - message to log
      params - parameters
    • fine Link icon

      public void fine(String msg, Object... params)
      Outputs a fine log event.
      Parameters:
      msg - message to log
      params - parameters
    • FINE Link icon

      public static void FINE(String msg, Throwable thrown)
      Outputs a fine log event.
      Parameters:
      msg - message to log
      thrown - thrown exception
    • fine Link icon

      public void fine(String msg, Throwable thrown)
      Outputs a fine log event.
      Parameters:
      msg - message to log
      thrown - thrown exception
    • FINE Link icon

      public static void FINE(Class<?> originator, String msg)
      Outputs a fine log event.
      Parameters:
      originator - originating class
      msg - message
    • FINE Link icon

      public static void FINE(Class<?> originator, String msg, Object param1)
      Outputs a fine log event.
      Parameters:
      originator - originating class
      msg - message
      param1 - first parameter
    • FINE Link icon

      public static void FINE(Class<?> originator, String msg, Object... params)
      Outputs a fine log event.
      Parameters:
      originator - originating class
      msg - message
      params - parameters
    • FINE Link icon

      public static void FINE(Class<?> originator, String msg, Throwable thrown)
      Outputs a fine log event.
      Parameters:
      originator - originating class
      msg - message
      thrown - thrown Exception
    • CONFIG Link icon

      public static void CONFIG(String msg)
      Outputs a config log event.
      Parameters:
      msg - message to log
    • config Link icon

      public void config(String msg)
      Outputs a config log event.
      Parameters:
      msg - message to log
    • CONFIG Link icon

      public static void CONFIG(String msg, Object param1)
      Outputs a config log event.
      Parameters:
      msg - message to log
      param1 - first parameter
    • config Link icon

      public void config(String msg, Object param1)
      Outputs a config log event.
      Parameters:
      msg - message to log
      param1 - first parameter
    • CONFIG Link icon

      public static void CONFIG(String msg, Object... params)
      Outputs a config log event.
      Parameters:
      msg - message to log
      params - parameters
    • config Link icon

      public void config(String msg, Object... params)
      Outputs a config log event.
      Parameters:
      msg - message to log
      params - parameters
    • CONFIG Link icon

      public static void CONFIG(String msg, Throwable thrown)
      Outputs a config log event.
      Parameters:
      msg - message to log
      thrown - thrown exception
    • config Link icon

      public void config(String msg, Throwable thrown)
      Outputs a config log event.
      Parameters:
      msg - message to log
      thrown - thrown exception
    • CONFIG Link icon

      public static void CONFIG(Class<?> originator, String msg)
      Outputs a config log event.
      Parameters:
      originator - originating class
      msg - message
    • CONFIG Link icon

      public static void CONFIG(Class<?> originator, String msg, Object param1)
      Outputs a config log event.
      Parameters:
      originator - originating class
      msg - message
      param1 - first parameter
    • CONFIG Link icon

      public static void CONFIG(Class<?> originator, String msg, Object... params)
      Outputs a config log event.
      Parameters:
      originator - originating class
      msg - message
      params - parameters
    • CONFIG Link icon

      public static void CONFIG(Class<?> originator, String msg, Throwable thrown)
      Outputs a config log event.
      Parameters:
      originator - originating class
      msg - message
      thrown - thrown Exception
    • INFO Link icon

      public static void INFO(String msg)
      Outputs an info log event.
      Parameters:
      msg - message to log
    • info Link icon

      public void info(String msg)
      Outputs an info log event.
      Parameters:
      msg - message to log
    • INFO Link icon

      public static void INFO(String msg, Object param1)
      Outputs an info log event.
      Parameters:
      msg - message to log
      param1 - first parameter
    • info Link icon

      public void info(String msg, Object param1)
      Outputs an info log event.
      Parameters:
      msg - message to log
      param1 - first parameter
    • INFO Link icon

      public static void INFO(String msg, Object... params)
      Outputs an info log event.
      Parameters:
      msg - message to log
      params - parameters
    • info Link icon

      public void info(String msg, Object... params)
      Outputs an info log event.
      Parameters:
      msg - message to log
      params - parameters
    • INFO Link icon

      public static void INFO(String msg, Throwable thrown)
      Outputs an info log event.
      Parameters:
      msg - message to log
      thrown - thrown exception
    • info Link icon

      public void info(String msg, Throwable thrown)
      Outputs an info log event.
      Parameters:
      msg - message to log
      thrown - thrown exception
    • INFO Link icon

      public static void INFO(Class<?> originator, String msg)
      Outputs an info log event.
      Parameters:
      originator - originating class
      msg - message
    • INFO Link icon

      public static void INFO(Class<?> originator, String msg, Object param1)
      Outputs an info log event.
      Parameters:
      originator - originating class
      msg - message
      param1 - first parameter
    • INFO Link icon

      public static void INFO(Class<?> originator, String msg, Object... params)
      Outputs an info log event.
      Parameters:
      originator - originating class
      msg - message
      params - parameters
    • INFO Link icon

      public static void INFO(Class<?> originator, String msg, Throwable thrown)
      Outputs an info log event.
      Parameters:
      originator - originating class
      msg - message
      thrown - thrown Exception
    • WARNING Link icon

      public static void WARNING(String msg)
      Outputs a warning log event.
      Parameters:
      msg - message to log
    • warning Link icon

      public void warning(String msg)
      Outputs a warning log event.
      Parameters:
      msg - message to log
    • WARNING Link icon

      public static void WARNING(String msg, Object param1)
      Outputs a warning log event.
      Parameters:
      msg - message to log
      param1 - first parameter
    • warning Link icon

      public void warning(String msg, Object param1)
      Outputs a warning log event.
      Parameters:
      msg - message to log
      param1 - first parameter
    • WARNING Link icon

      public static void WARNING(String msg, Object... params)
      Outputs a warning log event.
      Parameters:
      msg - message to log
      params - parameters
    • warning Link icon

      public void warning(String msg, Object... params)
      Outputs a warning log event.
      Parameters:
      msg - message to log
      params - parameters
    • WARNING Link icon

      public static void WARNING(String msg, Throwable thrown)
      Outputs a warning log event.
      Parameters:
      msg - message to log
      thrown - thrown exception
    • warning Link icon

      public void warning(String msg, Throwable thrown)
      Outputs a warning log event.
      Parameters:
      msg - message to log
      thrown - thrown exception
    • WARNING Link icon

      public static void WARNING(Class<?> originator, String msg)
      Outputs a warning log event.
      Parameters:
      originator - originating class
      msg - message
    • WARNING Link icon

      public static void WARNING(Class<?> originator, String msg, Object param1)
      Outputs a warning log event.
      Parameters:
      originator - originating class
      msg - message
      param1 - first parameter
    • WARNING Link icon

      public static void WARNING(Class<?> originator, String msg, Object... params)
      Outputs a warning log event.
      Parameters:
      originator - originating class
      msg - message
      params - parameters
    • WARNING Link icon

      public static void WARNING(Class<?> originator, String msg, Throwable thrown)
      Outputs a warning log event.
      Parameters:
      originator - originating class
      msg - message
      thrown - thrown Exception
    • SEVERE Link icon

      public static void SEVERE(String msg)
      Outputs a severe log event.
      Parameters:
      msg - message to log
    • severe Link icon

      public void severe(String msg)
      Outputs a severe log event.
      Parameters:
      msg - message to log
    • SEVERE Link icon

      public static void SEVERE(String msg, Object param1)
      Outputs a severe log event.
      Parameters:
      msg - message to log
      param1 - first parameter
    • severe Link icon

      public void severe(String msg, Object param1)
      Outputs a severe log event.
      Parameters:
      msg - message to log
      param1 - first parameter
    • SEVERE Link icon

      public static void SEVERE(String msg, Object... params)
      Outputs a severe log event.
      Parameters:
      msg - message to log
      params - parameters
    • severe Link icon

      public void severe(String msg, Object... params)
      Outputs a severe log event.
      Parameters:
      msg - message to log
      params - parameters
    • SEVERE Link icon

      public static void SEVERE(String msg, Throwable thrown)
      Outputs a severe log event.
      Parameters:
      msg - message to log
      thrown - thrown exception
    • severe Link icon

      public void severe(String msg, Throwable thrown)
      Outputs a severe log event.
      Parameters:
      msg - message to log
      thrown - thrown exception
    • SEVERE Link icon

      public static void SEVERE(Class<?> originator, String msg)
      Outputs a severe log event.
      Parameters:
      originator - originating class
      msg - message
    • SEVERE Link icon

      public static void SEVERE(Class<?> originator, String msg, Object param1)
      Outputs a severe log event.
      Parameters:
      originator - originating class
      msg - message
      param1 - first parameter
    • SEVERE Link icon

      public static void SEVERE(Class<?> originator, String msg, Object... params)
      Outputs a severe log event.
      Parameters:
      originator - originating class
      msg - message
      params - parameters
    • SEVERE Link icon

      public static void SEVERE(Class<?> originator, String msg, Throwable thrown)
      Outputs a severe log event.
      Parameters:
      originator - originating class
      msg - message
      thrown - thrown Exception
    • log Link icon

      public static void log(int level, String msg)
      Logs an event.
      Parameters:
      level - The log level.
      msg - The message.
    • log Link icon

      public static void log(int level, Class<?> clazz, String msg)
      Logs an event.
      Parameters:
      level - The log level.
      clazz - Event originates from class.
      msg - The message.
    • log Link icon

      public static void log(int level, String originator, String msg)
      Logs an event.
      Parameters:
      level - The log level.
      originator - Event originates from class or logger name.
      msg - The message.
    • log Link icon

      public static void log(int level, Class<?> clazz, String msg, Object param1)
      Logs an event.
      Parameters:
      level - The log level.
      clazz - Event originates from class.
      msg - The message.
      param1 - The single parameter.
    • log Link icon

      public static void log(int level, String originator, String msg, Object param1)
      Logs an event.
      Parameters:
      level - The log level.
      originator - Event originates from class or logger name.
      msg - The message.
      param1 - The single parameter.
    • log Link icon

      public static void log(int level, Class<?> clazz, String msg, Object... params)
      Logs an event.
      Parameters:
      level - The log level.
      clazz - Event originates from class.
      msg - The message.
      params - The list of parameters.
    • log Link icon

      public static void log(int level, String originator, String msg, Object... params)
      Logs an event.
      Parameters:
      level - The log level.
      originator - Event originates from class or logger name.
      msg - The message.
      params - The list of parameters.