Package org.opensourcephysics.controls
Class OSPLog
java.lang.Object
org.opensourcephysics.controls.OSPLog
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
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static Style
protected static Style
protected static final Color
protected static final Color
protected static final Color
protected static Style
protected static Style
static final Level[]
protected static boolean
protected static Style
protected int
static final PrintStream
protected static Style
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an OSPLog for a specified class.Constructs an OSPLog for a specified class and resource bundle.Constructs an OSPLog for a specified package.Constructs an OSPLog for a specified package and resource bundle. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addPropertyChangeListener
(PropertyChangeListener propertyChangeListener) static void
addPropertyChangeListener
(String name, PropertyChangeListener propertyChangeListener) void
clear()
Clears the log.static void
clearLog()
Clears the Log.static void
Logs a configuration message.protected void
Creates the GUI.protected Logger
Creates and initializes the logger.protected void
Creates the popup menu.static void
static void
static void
Logs a fine debugging message.static void
Logs a finer debugging message.static void
Logs a finest debugging message.protected void
firePropertyChange
(String propertyName, Object oldValue, Object newValue) Fires a property change event.protected static JFileChooser
Gets a file chooser.protected Handler
Gets the file handler using lazy instantiation.static JFrame
getFrame()
static int
Gets the logger level value.Gets the directory where the log file will be saved if logging is enabled.Gets the logger.Gets the log panel so it can be displayed in a dialog or other container.static OSPLog
Gets the OSPLog that can be shared by multiple OSP packages.static void
getOSPLog
(boolean useFrame) static void
Logs an information message.static boolean
Gets whether console messages are logged.static boolean
Determines if the shared log is visible.boolean
Determines if the log is visible.static void
void
open()
Opens a text file selected with a chooser and writes the contents to the log.void
Opens a text file specified by name and writes the contents to the log.static Level
parseLevel
(String level) Returns the Level with the specified name, or null if none.protected String
Reads a file.static void
removePropertyChangeListener
(PropertyChangeListener propertyChangeListener) Saves the log to a text file specified by name.Saves a log to a text file selected with a chooser.Saves the xml-formatted log records to a file specified by name.Saves the xml-formatted log records to a file selected with a chooser.static void
setConsoleMessagesLogged
(boolean log) Sets whether console messages are logged.static void
setFonts
(int level) static void
Sets the logger level.void
Sets the directory where the log file will be saved if logging is enabled.void
setLogToFileAction
(boolean enable) Enables logging to a file.void
setVisible
(boolean visible) Sets the visibility of this log.static void
Logs a severe error message.static JFrame
showLog()
Shows the log when it is invoked from the event queue.static void
Shows the log.static void
Logs a warning message.
-
Field Details
-
realSysout
-
black
-
red
-
blue
-
green
-
magenta
-
gray
-
DARK_GREEN
-
DARK_BLUE
-
DARK_RED
-
levels
-
logConsole
protected static boolean logConsole -
myPopupFontLevel
protected int myPopupFontLevel
-
-
Constructor Details
-
OSPLog
Constructs an OSPLog for a specified package.- Parameters:
pkg
- the package
-
OSPLog
Constructs an OSPLog for a specified package and resource bundle.- Parameters:
pkg
- the packageresourceBundleName
- the name of the resource bundle
-
OSPLog
Constructs an OSPLog for a specified class.- Parameters:
type
- the class
-
OSPLog
Constructs an OSPLog for a specified class and resource bundle.- Parameters:
type
- the classresourceBundleName
- the name of the resource bundle
-
-
Method Details
-
getOSPLog
Gets the OSPLog that can be shared by multiple OSP packages.- Returns:
- the shared OSPLog
-
getOSPLog
public static void getOSPLog(boolean useFrame) -
setLogDir
Sets the directory where the log file will be saved if logging is enabled.- Parameters:
dir
- 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
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
Sets the logger level.- Parameters:
level
- the Level
-
parseLevel
Returns the Level with the specified name, or null if none.- Parameters:
level
- the Level
-
severe
Logs a severe error message.- Parameters:
msg
- the message
-
warning
Logs a warning message.- Parameters:
msg
- the message
-
info
Logs an information message.- Parameters:
msg
- the message
-
config
Logs a configuration message.- Parameters:
msg
- the message
-
fine
Logs a fine debugging message.- Parameters:
msg
- the message
-
clearLog
public static void clearLog()Clears the Log.- Parameters:
msg
- the message
-
finer
Logs a finer debugging message.- Parameters:
msg
- the message
-
finest
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
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
Saves the log to a text file specified by name.- Parameters:
fileName
- the file name- Returns:
- the name of the file
-
saveLogAs
Saves a log to a text file selected with a chooser.- Returns:
- the name of the file
-
saveXML
Saves the xml-formatted log records to a file specified by name.- Parameters:
fileName
- the file name- Returns:
- the name of the file
-
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
Opens a text file specified by name and writes the contents to the log.- Parameters:
fileName
- the file name
-
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
Fires a property change event. Needed to expose protected method. -
createGUI
protected void createGUI()Creates the GUI. -
createLogger
Creates and initializes the logger.- Returns:
- the logger
-
getFileHandler
Gets the file handler using lazy instantiation.- Returns:
- the Handler
-
createMenus
protected void createMenus()Creates the popup menu. -
getChooser
Gets a file chooser.- Returns:
- the chooser
-
read
Reads a file.- Parameters:
fileName
- the name of the file- Returns:
- the file contents as a String
-
debug
-
setFonts
public static void setFonts(int level) -
finalized
-
notify
-
getFrame
-
addPropertyChangeListener
-
removePropertyChangeListener
-
addPropertyChangeListener
public static void addPropertyChangeListener(String name, PropertyChangeListener propertyChangeListener)
-