Class Console

java.lang.Object
com.iizigo.Console
All Implemented Interfaces:
ILoggerRedirector

public class Console extends Object implements ILoggerRedirector
Console class with colors.

The log file. Everything the IIZI Console shows (the IIZI log, System.out and System.err) is also written, same text and order, into a log file in a slot of LOG_DIR (iiziGo-console-1.log to iiziGo-console-10.log, the oldest or a missing one taken at each start, a slot a running iiziGo holds skipped: SlotLogFile). The feeder thread writes it, never the SWT thread, and flushes after each batch it drains; the texts the console view drops under a burst still reach the file. The file starts with a header (its own path, the start time, then the program info: the lines of the console view's first entry, "Program info:"), the last line of that entry names its path, and past LOG_MAX_SIZE the log continues in the next slot. The file is one static stream for the process (SlotLogFile.getCurrent()): it is not closed when the bundle stops or the console view is removed, only when a new log file is opened or by the end of the process; a bundle restart without a class reload finds the console's statics and the open file as they are, and reuses them (order CC-IIZIGO-CONSOLE-LOG-FILE, rulings L-1 to L-4).

Author:
Christopher Mindus
  • Field Details

    • LOG_DIR_PROPERTY

      public static final String LOG_DIR_PROPERTY
      The system property that names another directory for the console log files than the per-user folder. A test launch sets it (the Designer UI harness of com.iizigo.term.tests, in its pom), so that the slots of test runs do not take those of the user's own iiziGo: on a machine that runs both, the ten slots of the per-user folder were overwritten by test runs within hours. A relative path is resolved against the working directory. Not set or blank: the per-user folder, as for every iiziGo a user starts.
      See Also:
    • LOG_DIR

      public static final File LOG_DIR
      The directory of the console log files: <user home>/.iizi/com.iizigo/logs (ruling L-2), or the directory LOG_DIR_PROPERTY names. Computed here rather than taken from the Activator: the console starts inside the Activator's static initializer, before its directories exist.
    • TYPE_stderr

      public static final int TYPE_stderr
      The types.
      See Also:
    • TYPE_stdout

      public static final int TYPE_stdout
      See Also:
    • TYPE_log_SEVERE

      public static final int TYPE_log_SEVERE
      See Also:
    • TYPE_log_WARNING

      public static final int TYPE_log_WARNING
      See Also:
    • TYPE_log_INFO

      public static final int TYPE_log_INFO
      See Also:
    • TYPE_log_CONFIG

      public static final int TYPE_log_CONFIG
      See Also:
    • TYPE_log_FINE

      public static final int TYPE_log_FINE
      See Also:
    • TYPE_log_FINER

      public static final int TYPE_log_FINER
      See Also:
    • TYPE_log_FINEST

      public static final int TYPE_log_FINEST
      See Also:
    • LIGHT_THEME_COLORS

      public static final int[] LIGHT_THEME_COLORS
      Light theme colors.
    • DARK_THEME_COLORS

      public static final int[] DARK_THEME_COLORS
      Dark theme colors.
  • Method Details

    • getPrintAdapter

      public static IPrintAdapter getPrintAdapter()
      Gets the printer to use for simple console output.
      Returns:
      The instance.
    • getLogFile

      public static File getLogFile()
      Gets the console's log file.
      Returns:
      The log file the console writes, or null when file logging is off (see getLogFileFailure()).
    • getLogFileFailure

      public static String getLogFileFailure()
      Gets why file logging is off.
      Returns:
      The failure that stopped the file logging, or null when there is none.
    • onEventLogged

      public void onEventLogged(LogEntry entry)
      Called when an event is logged.
      Specified by:
      onEventLogged in interface ILoggerRedirector
      Parameters:
      entry - The log entry.
    • eprintln

      public static void eprintln(String msg)
      Prints a stderr message.
      Parameters:
      msg - The message to print.
    • println

      public static void println(String msg)
      Prints a stdout message.
      Parameters:
      msg - The message to print.
    • println

      public static void println(int type, String msg)
      Prints to any of the stream types.
      Parameters:
      type - The type of message:
        TYPE_stderr      = 0
        TYPE_stdout      = 1
        TYPE_log_SEVERE  = 2
        TYPE_log_WARNING = 3
        TYPE_log_INFO    = 4
        TYPE_log_CONFIG  = 5
        TYPE_log_FINE    = 6
        TYPE_log_FINER   = 7
        TYPE_log_FINEST  = 8
      
      msg - The message to print.