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

  • Constructor Details

    • ILog

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

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

    • mapJSLogLevelToJava

      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

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

      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

      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

      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

      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

      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

      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

      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

      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

      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

      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

      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

      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

      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

      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

      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

      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

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

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

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

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

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

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

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

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

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

      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

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

      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

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

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

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

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

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

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

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

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

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

      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

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

      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

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

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

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

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

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

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

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

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

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

      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

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

      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

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

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

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

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

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

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

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

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

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

      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

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

      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

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

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

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

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

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

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

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

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

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

      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

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

      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

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

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

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

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

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

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

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

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

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

      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

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

      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

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

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

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

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

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

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

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

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

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

      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

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

      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

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

      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

      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

      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

      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

      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

      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.