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 classa log-entry renderer for a list and a status-barstatic interfacemethods of the interface might happen outside of event threadstatic classa window for displaying log-liststatic classan 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 GuiLogManagerConsolestatic booleanstatic booleanstatic booleanstatic booleanstatic booleanprotected List<GuiSwingLogManager.GuiSwingLogView> Fields inherited from class org.autogui.base.log.GuiLogManager
manager -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddView(Consumer<GuiLogEntry> view) voidclear()callGuiSwingLogManager.GuiSwingLogView.clearLogEntries()to viewsgetErr()static FontgetFont()static GuiSwingLogManagercreate an exception entry and show itcreate an active progress entry and show it.create a string entry and show it.voidremoveView(Object v) voidsetConsole(GuiLogManagerConsole console) static voidsetDefaultReplace(boolean flag) static voidsetRedirectToConsole(boolean flag) static voidsetSuppressOutputRedirection(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.voidshow(GuiLogEntry e) update display of the entry.voidMethods 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.errfor redirection to the GUI listreplaceOutput- replaceSystem.outfor redirection to the GUI listuncaughtHandler- replace the uncaught-handler for redirection to the GUI listredirectToConsole- addingGuiLogManagerConsoleto 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:
getErrin classGuiLogManager
-
logString
Description copied from class:GuiLogManagercreate a string entry and show it.- Overrides:
logStringin 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:GuiLogManagercreate an exception entry and show it- Overrides:
logErrorin classGuiLogManager- Parameters:
ex- the exception- Returns:
- the created entry
-
logProgress
Description copied from class:GuiLogManagercreate 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:
logProgressin classGuiLogManager- Returns:
- the created progress entry
-
updateProgress
- Overrides:
updateProgressin classGuiLogManager
-
show
Description copied from class:GuiLogManagerupdate display of the entry.- Overrides:
showin classGuiLogManager- Parameters:
e- the displayed entry
-
clear
public void clear()callGuiSwingLogManager.GuiSwingLogView.clearLogEntries()to views- Since:
- 1.2
-
getFont
-
createWindow
-