Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Scout/HowTo/3.8/Make use of the additional Scout logging features
The Scout documentation has been moved to https://eclipsescout.github.io/.
The snipped below demonstrates you how to register keystrokes in Scout desktop to make use of the additional logging functionality:
With the keystrokes 'CTRL-Shift-1' to 'CTRL-Shift-4', the log level can be changed at runtime. Also, recording of log messages is turned on if not the case yet.
To cancel recording and set the configuration to its origin state, 'CTRL-Shift-0' can be pressed.
public class Desktop extends AbstractDesktop { /** * Instruct {@link ScoutLogManager} to load its origin logging configuration and turn off recording of log messages. * If recording was active, a file is displayed to the user containing all log messages since recording was started. */ @Order(10) public class LogLevelDefaultKeyStroke extends AbstractKeyStroke { @Override protected String getConfiguredKeyStroke() { return "ctrl-shift-0"; } @Override protected void execAction() throws ProcessingException { ScoutLogManager.setGlobalLogLevel(null); File file = ScoutLogManager.stopRecording(); if (file != null) { Desktop.this.setStatusText("LOG level is set back to default and recording of log messages turned off"); SERVICES.getService(IShellService.class).shellOpen(file.getAbsolutePath()); } else { Desktop.this.setStatusText("LOG level is set back to normal"); } } } /** * Instruct {@link ScoutLogManager} to only log messages of the severity ERROR and worse. * Also, turn on recording of log messages if not done yet. */ @Order(20) public class LogLevelErrorKeyStroke extends AbstractKeyStroke { @Override protected String getConfiguredKeyStroke() { return "ctrl-shift-1"; } @Override protected void execAction() throws ProcessingException { ScoutLogManager.setGlobalLogLevel(IScoutLogger.LEVEL_ERROR); if (ScoutLogManager.startRecording()) { Desktop.this.setStatusText("LOG level is set to ERROR and recording of log messages turned on"); } else { Desktop.this.setStatusText("LOG level is set to ERROR"); } } } /** * Instruct {@link ScoutLogManager} to only log messages of the severity WARNING and worse. * Also, turn on recording of log messages if not done yet. */ @Order(30) public class LogLevelWarningKeyStroke extends AbstractKeyStroke { @Override protected String getConfiguredKeyStroke() { return "ctrl-shift-2"; } @Override protected void execAction() throws ProcessingException { ScoutLogManager.setGlobalLogLevel(IScoutLogger.LEVEL_WARN); if (ScoutLogManager.startRecording()) { Desktop.this.setStatusText("LOG level is set to WARNING and recording of log messages turned on"); } else { Desktop.this.setStatusText("LOG level is set to WARNING"); } } } /** * Instruct {@link ScoutLogManager} to only log messages of the severity INFO and worse. * Also, turn on recording of log messages if not done yet. */ @Order(40) public class LogLevelInfoKeyStroke extends AbstractKeyStroke { @Override protected String getConfiguredKeyStroke() { return "ctrl-shift-3"; } @Override protected void execAction() throws ProcessingException { ScoutLogManager.setGlobalLogLevel(IScoutLogger.LEVEL_INFO); if (ScoutLogManager.startRecording()) { Desktop.this.setStatusText("LOG level is set to INFO and recording of log messages turned on"); } else { Desktop.this.setStatusText("LOG level is set to INFO"); } } } /** * Instruct {@link ScoutLogManager} to only log messages of the severity DEBUG and worse. * Also, turn on recording of log messages if not done yet. */ @Order(50) public class DebugLogLevelKeyStroke extends AbstractKeyStroke { @Override protected String getConfiguredKeyStroke() { return "ctrl-shift-4"; } @Override protected void execAction() throws ProcessingException { ScoutLogManager.setGlobalLogLevel(IScoutLogger.LEVEL_DEBUG); if (ScoutLogManager.startRecording()) { Desktop.this.setStatusText("LOG level is set to DEBUG and recording of log messages turned on"); } else { Desktop.this.setStatusText("LOG level is set to DEBUG"); } } } }