java.lang.Object
org.autogui.base.log.GuiLogManager
org.autogui.swing.log.GuiSwingLogManager
a log-manager supporting Swing GUI
GuiSwingLogManager m = new GuiSwingLogManager(); m.setupConsole( GuiSwingLogManager.replaceErr, GuiSwingLogManager.replaceOut, GuiSwingLogManager.replaceExceptionHandler, GuiSwingLogManager.redirectToConsole, GuiSwingLogManager.suppressOutputRedirection); GuiLogManager.setManager(m); ... frame.setContentPane(m.createWindow().getPaneWithStatusBar(frame.getContentPane())); ... GuiLogManager.log(...);
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
a log-entry renderer for a list and a status-barstatic interface
methods of the interface might happen outside of event threadstatic class
a window for displaying log-liststatic class
an action for showing the log-list, displayed on a status-barNested classes/interfaces inherited from class org.autogui.base.log.GuiLogManager
GuiLogManager.LogOutputStream, GuiLogManager.LogPrintStream, GuiLogManager.LogStreamType, GuiLogManager.LogUncaughtHandler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected GuiLogManagerConsole
static boolean
static boolean
static boolean
static boolean
static boolean
protected List
<GuiSwingLogManager.GuiSwingLogView> Fields inherited from class org.autogui.base.log.GuiLogManager
manager
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddView
(Consumer<GuiLogEntry> view) void
clear()
callGuiSwingLogManager.GuiSwingLogView.clearLogEntries()
to viewsgetErr()
static Font
getFont()
static GuiSwingLogManager
create an exception entry and show itcreate an active progress entry and show it.create a string entry and show it.void
removeView
(Object v) void
setConsole
(GuiLogManagerConsole console) static void
setDefaultReplace
(boolean flag) static void
setRedirectToConsole
(boolean flag) static void
setSuppressOutputRedirection
(boolean flag) setupConsole
(boolean replaceError, boolean replaceOutput, boolean uncaughtHandler, boolean redirectToConsole) setupConsole
(boolean replaceError, boolean replaceOutput, boolean uncaughtHandler, boolean redirectToConsole, boolean suppressOutputRedirection) controls logging redirection.the method callssetupConsole(boolean, boolean, boolean, boolean, boolean)
with reading following properties with conjunction of static fields.void
show
(GuiLogEntry e) update display of the entry.void
Methods inherited from class org.autogui.base.log.GuiLogManager
formatDuration, formatMessageLine, formatTime, get, getSystemErr, isSymbol, log, logFormat, logProgress, logString, replaceConsole, replaceUncaughtHandler, resetErr, resetOut, resetUncaughtHandler, setManager
-
Field Details
-
views
-
console
-
replaceErr
public static boolean replaceErr -
replaceOut
public static boolean replaceOut -
replaceExceptionHandler
public static boolean replaceExceptionHandler -
redirectToConsole
public static boolean redirectToConsole -
suppressOutputRedirection
public static boolean suppressOutputRedirection- Since:
- 1.1
-
-
Constructor Details
-
GuiSwingLogManager
public GuiSwingLogManager()
-
-
Method Details
-
setDefaultReplace
public static void setDefaultReplace(boolean flag) -
setRedirectToConsole
public static void setRedirectToConsole(boolean flag) -
setSuppressOutputRedirection
public static void setSuppressOutputRedirection(boolean flag) - Parameters:
flag
- flag forsuppressOutputRedirection
- Since:
- 1.1
-
addView
- Parameters:
view
- might accept same entries- Returns:
- key object for removing, currently view itself
-
addView
- Parameters:
view
- a view for log entries, might accept same entries- Returns:
- key object for removing, currently view itself
- Since:
- 1.2
-
removeView
-
setConsole
-
getConsole
-
getOrSetSwingLogManager
- Returns:
- existing manager from
GuiLogManager.get()
or a new manager - Since:
- 1.1
-
setupConsoleWithDefaultFlags
the method callssetupConsole(boolean, boolean, boolean, boolean, boolean)
with reading following properties with conjunction of static fields. those properties take "true" (default) or "false".- autogui.log.replaceErr
- autogui.log.replaceOut
- autogui.log.replaceExceptionHandler
- autogui.log.redirectToConsole
- autogui.log.suppressOutputRedirection
- Returns:
- this
- Since:
- 1.1
- See Also:
-
setupConsole
public GuiLogManager setupConsole(boolean replaceError, boolean replaceOutput, boolean uncaughtHandler, boolean redirectToConsole) -
setupConsole
public GuiLogManager setupConsole(boolean replaceError, boolean replaceOutput, boolean uncaughtHandler, boolean redirectToConsole, boolean suppressOutputRedirection) controls logging redirection.setupConsole(true, true, true, true, true); //default: redirect to console and GUI-list System.err.print("msg"); // => stderr: "[Time...] msg", GUI-list: "[Time...] msg" System.out.print("msg"); // => stdout: "msg", GUI-list: "[Time...] msg" logString("msg"); // => stderr: "[Time...] msg", GUI-list: "[Time...] msg" setupConsole(false, false, true, true, true); //no stdout/stderr replacement. System.err.print("msg"); // => stderr: "msg" System.out.print("msg"); // => stdout: "msg" logString("msg"); // => stderr: "[Time...] msg", GUI-list: "[Time...] msg" setupConsole(true, true, true, false, true); //no console redirection: only stdout directly write message to the console as outputs System.err.print("msg"); // => GUI-list: "[Time...] msg" System.out.print("msg"); // => stdout: "msg", GUI-list: "[Time...] msg" logString("msg"); // => GUI-list: "[Time...] msg" setupConsole(false, false, true, false, true); //no stdout/stderr replacement, and no console redirection: stdout/stderr just work as original System.err.print("msg"); // => stderr: "msg" System.out.print("msg"); // => stdout: "msg" logString("msg"); // => GUI-list: "[Time...] msg" setupConsole(true, true, true, true, false); //full redirection: stdout also writes to stderr System.err.print("msg"); // => stderr: "[Time...] msg", GUI-list: "[Time...] msg" System.out.print("msg"); // => stderr: "[Time...] msg", stdout: "msg", GUI-list: "[Time...] msg" logString("msg"); // => stderr: "[Time...] msg", GUI-list: "[Time...] msg"
- Parameters:
replaceError
- replaceSystem.err
for redirection to the GUI listreplaceOutput
- replaceSystem.out
for redirection to the GUI listuncaughtHandler
- replace the uncaught-handler for redirection to the GUI listredirectToConsole
- addingGuiLogManagerConsole
to the manager: this means that the GUI list redirects to the console (originalSystem.err
)suppressOutputRedirection
- avoiding redirection of redirectToConsole from replaced System.out. So work only if replaceOutput=true and redirectToConsole=true- Returns:
- this
- Since:
- 1.1
-
getErr
- Overrides:
getErr
in classGuiLogManager
-
logString
Description copied from class:GuiLogManager
create a string entry and show it.- Overrides:
logString
in classGuiLogManager
- Parameters:
str
- the string for the entryfromStandard
- whether the string come from the standard output (or error) redirection- Returns:
- the created log entry
-
logError
Description copied from class:GuiLogManager
create an exception entry and show it- Overrides:
logError
in classGuiLogManager
- Parameters:
ex
- the exception- Returns:
- the created entry
-
logProgress
Description copied from class:GuiLogManager
create an active progress entry and show it. the returned progress is determinate (isIndeterminate() == false), and notifies progress changes to the manager byGuiLogManager.updateProgress(GuiLogEntryProgress)
try (GuiLogEntryProgress p = manager.logProgress();) { for (...) { //those methods will cause a runtime-exception if the thread is interrupted. p.addValueP(0.01f) .setMessage("running ..."); ... //the running code can checks interruption if (Thread.interrupted()) { break; } ... } } catch (Exception ex) { ... }
- Overrides:
logProgress
in classGuiLogManager
- Returns:
- the created progress entry
-
updateProgress
- Overrides:
updateProgress
in classGuiLogManager
-
show
Description copied from class:GuiLogManager
update display of the entry.- Overrides:
show
in classGuiLogManager
- Parameters:
e
- the displayed entry
-
clear
public void clear()callGuiSwingLogManager.GuiSwingLogView.clearLogEntries()
to views- Since:
- 1.2
-
getFont
-
createWindow
-