Class SystemOutUtilities


  • public class SystemOutUtilities
    extends java.lang.Object
    A class that allow redirection of stderr and/or stdout to a log file. Invokation of this class must be done with "SystemOutUtilities.instance()" which return a reference to the singleton.
    Since:
    PicEdt 1.3
    Version:
    $Id: SystemOutUtilities.java,v 1.7.2.1 2007/09/02 11:56:30 reynal Exp $
    Author:
    Sylvain Reynal
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int FILE
      redirects stdout to a file named "jPicedtError.log"
      static int STANDARD
      doesn't redirect stdout to a file, ie redirect to console ; instead open a frame and displays the error message in it
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void displayDialog​(boolean state)
      Sets the "displayDialog" flag, ie what must happen when an error message comes up and redir=FILE : do we open a JDialog or simply write the error message to the log file ? (obviously, calling this method if redir=STANDARD simply makes no sense)
      static java.lang.String getErrorLogFile()
      Return the path to error.log
      static SystemOutUtilities instance()
      intanciates singleton if it's null, then returns it
      void redirect​(int type)
      Redirect to the stream of the given type
      • Methods inherited from class java.lang.Object

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

      • STANDARD

        public static final int STANDARD
        doesn't redirect stdout to a file, ie redirect to console ; instead open a frame and displays the error message in it
        See Also:
        Constant Field Values
      • FILE

        public static final int FILE
        redirects stdout to a file named "jPicedtError.log"
        See Also:
        Constant Field Values
    • Method Detail

      • instance

        public static SystemOutUtilities instance()
        intanciates singleton if it's null, then returns it
      • redirect

        public void redirect​(int type)
        Redirect to the stream of the given type
        Parameters:
        type - one of the predefinite SystemOutUtilities's redirection types
      • displayDialog

        public void displayDialog​(boolean state)
        Sets the "displayDialog" flag, ie what must happen when an error message comes up and redir=FILE : do we open a JDialog or simply write the error message to the log file ? (obviously, calling this method if redir=STANDARD simply makes no sense)
        Parameters:
        state - if currentRedir = FILE and : - state==TRUE, enables opening a dialog box whenever some String is written to System.out A "watchdog" Thread is created for that purpose : System.out is redirected to a pipe, which the Thread watches periodically. - state==FALSE, redirect System.out directly to the "toFilePrintStream" FOS, and kill the watchdog Thread if it's still alive. Otherwise (ie currentRedir = STANDARD), we do nothing.
      • getErrorLogFile

        public static java.lang.String getErrorLogFile()
        Return the path to error.log