Class OSPLog

java.lang.Object
org.opensourcephysics.controls.OSPLog

public class OSPLog extends Object
This is a viewable file-based message log for a java package. It displays log records in a text pane and saves them in a temp file.
Version:
1.0
Author:
Douglas Brown, Wolfgang Christian
  • Field Details

    • realSysout

      public static final PrintStream realSysout
    • black

      protected static Style black
    • red

      protected static Style red
    • blue

      protected static Style blue
    • green

      protected static Style green
    • magenta

      protected static Style magenta
    • gray

      protected static Style gray
    • DARK_GREEN

      protected static final Color DARK_GREEN
    • DARK_BLUE

      protected static final Color DARK_BLUE
    • DARK_RED

      protected static final Color DARK_RED
    • levels

      public static final Level[] levels
    • logConsole

      protected static boolean logConsole
    • myPopupFontLevel

      protected int myPopupFontLevel
  • Constructor Details

    • OSPLog

      public OSPLog(Package pkg)
      Constructs an OSPLog for a specified package.
      Parameters:
      pkg - the package
    • OSPLog

      public OSPLog(Package pkg, String resourceBundleName)
      Constructs an OSPLog for a specified package and resource bundle.
      Parameters:
      pkg - the package
      resourceBundleName - the name of the resource bundle
    • OSPLog

      public OSPLog(Class<?> type)
      Constructs an OSPLog for a specified class.
      Parameters:
      type - the class
    • OSPLog

      public OSPLog(Class<?> type, String resourceBundleName)
      Constructs an OSPLog for a specified class and resource bundle.
      Parameters:
      type - the class
      resourceBundleName - the name of the resource bundle
  • Method Details

    • getOSPLog

      public static OSPLog getOSPLog()
      Gets the OSPLog that can be shared by multiple OSP packages.
      Returns:
      the shared OSPLog
    • getOSPLog

      public static void getOSPLog(boolean useFrame)
    • setLogDir

      public void setLogDir(String dir)
      Sets the directory where the log file will be saved if logging is enabled.
      Parameters:
      dir - String
    • getLogDir

      public String getLogDir()
      Gets the directory where the log file will be saved if logging is enabled.
      Parameters:
      dir - String
    • isLogVisible

      public static boolean isLogVisible()
      Determines if the shared log is visible.
      Returns:
      true if visible
    • setVisible

      public void setVisible(boolean visible)
      Sets the visibility of this log.
      Parameters:
      true - to set visible
    • isVisible

      public boolean isVisible()
      Determines if the log is visible.
      Returns:
      true if visible
    • showLog

      public static JFrame showLog()
      Shows the log when it is invoked from the event queue.
    • showLogInvokeLater

      public static void showLogInvokeLater()
      Shows the log.
    • getLevelValue

      public static int getLevelValue()
      Gets the logger level value.
      Returns:
      the current level value
    • setLevel

      public static void setLevel(Level level)
      Sets the logger level.
      Parameters:
      level - the Level
    • parseLevel

      public static Level parseLevel(String level)
      Returns the Level with the specified name, or null if none.
      Parameters:
      level - the Level
    • severe

      public static void severe(String msg)
      Logs a severe error message.
      Parameters:
      msg - the message
    • warning

      public static void warning(String msg)
      Logs a warning message.
      Parameters:
      msg - the message
    • info

      public static void info(String msg)
      Logs an information message.
      Parameters:
      msg - the message
    • config

      public static void config(String msg)
      Logs a configuration message.
      Parameters:
      msg - the message
    • fine

      public static void fine(String msg)
      Logs a fine debugging message.
      Parameters:
      msg - the message
    • clearLog

      public static void clearLog()
      Clears the Log.
      Parameters:
      msg - the message
    • finer

      public static void finer(String msg)
      Logs a finer debugging message.
      Parameters:
      msg - the message
    • finest

      public static void finest(String msg)
      Logs a finest debugging message.
      Parameters:
      msg - the message
    • setConsoleMessagesLogged

      public static void setConsoleMessagesLogged(boolean log)
      Sets whether console messages are logged.
      Parameters:
      log - true to log console messages
    • isConsoleMessagesLogged

      public static boolean isConsoleMessagesLogged()
      Gets whether console messages are logged.
      Returns:
      true if console messages are logged
    • getLogPanel

      public JPanel getLogPanel()
      Gets the log panel so it can be displayed in a dialog or other container.
      Returns:
      a JPanel containing the log
    • clear

      public void clear()
      Clears the log.
    • saveLog

      public String saveLog(String fileName)
      Saves the log to a text file specified by name.
      Parameters:
      fileName - the file name
      Returns:
      the name of the file
    • saveLogAs

      public String saveLogAs()
      Saves a log to a text file selected with a chooser.
      Returns:
      the name of the file
    • saveXML

      public String saveXML(String fileName)
      Saves the xml-formatted log records to a file specified by name.
      Parameters:
      fileName - the file name
      Returns:
      the name of the file
    • saveXMLAs

      public String saveXMLAs()
      Saves the xml-formatted log records to a file selected with a chooser.
      Returns:
      the name of the file
    • open

      public void open()
      Opens a text file selected with a chooser and writes the contents to the log.
    • open

      public void open(String fileName)
      Opens a text file specified by name and writes the contents to the log.
      Parameters:
      fileName - the file name
    • getLogger

      public Logger getLogger()
      Gets the logger.
      Returns:
      the logger
    • setLogToFileAction

      public void setLogToFileAction(boolean enable)
      Enables logging to a file.
      Parameters:
      enable - true to log to a file
    • firePropertyChange

      protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
      Fires a property change event. Needed to expose protected method.
    • createGUI

      protected void createGUI()
      Creates the GUI.
    • createLogger

      protected Logger createLogger()
      Creates and initializes the logger.
      Returns:
      the logger
    • getFileHandler

      protected Handler getFileHandler()
      Gets the file handler using lazy instantiation.
      Returns:
      the Handler
    • createMenus

      protected void createMenus()
      Creates the popup menu.
    • getChooser

      protected static JFileChooser getChooser()
      Gets a file chooser.
      Returns:
      the chooser
    • read

      protected String read(String fileName)
      Reads a file.
      Parameters:
      fileName - the name of the file
      Returns:
      the file contents as a String
    • debug

      public static void debug(String msg)
    • setFonts

      public static void setFonts(int level)
    • finalized

      public static void finalized(Object c)
    • notify

      public static void notify(Object c, String msg)
    • getFrame

      public static JFrame getFrame()
    • addPropertyChangeListener

      public static void addPropertyChangeListener(PropertyChangeListener propertyChangeListener)
    • removePropertyChangeListener

      public static void removePropertyChangeListener(PropertyChangeListener propertyChangeListener)
    • addPropertyChangeListener

      public static void addPropertyChangeListener(String name, PropertyChangeListener propertyChangeListener)