[logback-dev] svn commit: r1349 - in logbackPDE/trunk/plugins/ConsolePlugin: . src/main/java/ch/qos/logback/eclipse/views
noreply.seb at qos.ch
noreply.seb at qos.ch
Fri Feb 23 18:10:27 CET 2007
Author: seb
Date: Fri Feb 23 18:10:27 2007
New Revision: 1349
Modified:
logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LoggingEventContentProvider.java
logbackPDE/trunk/plugins/ConsolePlugin/todo.txt
Log:
Changed the way we deal with streams.
This version should resist to a flow of 100'000 logging events sent without pause :)
Updated todo list
Modified: logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LoggingEventContentProvider.java
==============================================================================
--- logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LoggingEventContentProvider.java (original)
+++ logbackPDE/trunk/plugins/ConsolePlugin/src/main/java/ch/qos/logback/eclipse/views/LoggingEventContentProvider.java Fri Feb 23 18:10:27 2007
@@ -14,6 +14,7 @@
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.spi.LoggingEvent;
+import ch.qos.logback.eclipse.PluginLogger;
import ch.qos.logback.eclipse.model.LoggingEventManagerEvent;
import ch.qos.logback.eclipse.model.LoggingEventManagerListener;
@@ -24,108 +25,76 @@
*/
public class LoggingEventContentProvider implements LoggingEventManagerListener {
-// private MessageConsoleStream redStream;
-// private MessageConsoleStream blackStream;
-// private int count = 0;
-// private static int MAX_COUNT = 1000;
- private MessageConsole console;
+ private MessageConsoleStream redStream;
+ private MessageConsoleStream blackStream;
private TextConsoleViewer viewer;
private Color cachedRed;
private Color cachedBlack;
private LabelProvider labelProvider;
-
+
public LoggingEventContentProvider(MessageConsole console, TextConsoleViewer viewer) {
Display display = Display.getCurrent();
- cachedRed = new Color(display, 255, 0,0);
- cachedBlack = new Color(display, 0, 0,0);
- this.console = console;
+ cachedRed = new Color(display, 255, 0, 0);
+ cachedBlack = new Color(display, 0, 0, 0);
this.viewer = viewer;
-// redStream = console.newMessageStream();
-// redStream.setColor(cachedRed);
-// blackStream = console.newMessageStream();
-// blackStream.setColor(cachedBlack);
+
+ redStream = console.newMessageStream();
+ redStream.setColor(cachedRed);
+ blackStream = console.newMessageStream();
+ blackStream.setColor(cachedBlack);
}
WorkbenchJob revealJob = new WorkbenchJob("Reveal End of Document") {//$NON-NLS-1$
public IStatus runInUIThread(IProgressMonitor monitor) {
- StyledText textWidget = viewer.getTextWidget();
- if (textWidget != null) {
- int lineCount = textWidget.getLineCount();
- textWidget.setTopIndex(lineCount - 1);
- }
- return Status.OK_STATUS;
+ StyledText textWidget = viewer.getTextWidget();
+ if (textWidget != null) {
+ int lineCount = textWidget.getLineCount();
+ textWidget.setTopIndex(lineCount - 1);
+ }
+ return Status.OK_STATUS;
}
-};
+ };
public void dispose() {
cachedRed.dispose();
cachedBlack.dispose();
-// try {
-// redStream.close();
-// blackStream.close();
-// } catch (Exception e) {
-// PluginLogger.logError(e);
-// }
+ try {
+ redStream.close();
+ blackStream.close();
+ } catch (Exception e) {
+ PluginLogger.logError(e);
+ }
}
public void loggingEventsChanged(final LoggingEventManagerEvent event) {
-
- // If this is the UI thread, then make the change
- if (Display.getCurrent() != null) {
- updateViewer(event);
- return;
- }
-
- // otherwise redirect to execute on the UI thread
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- updateViewer(event);
- }
- });
+ updateViewer(event);
}
- private void updateViewer(final LoggingEventManagerEvent event) {
+ private void updateViewer(final LoggingEventManagerEvent event) {
LoggingEvent le = (LoggingEvent) event.getItemsAdded()[0];
-// if (le.getLevel().isGreaterOrEqual(Level.WARN)) {
-// redStream.println(labelProvider.getText(le));
-// } else {
-// blackStream.println(labelProvider.getText(le));
-// }
-// count ++;
-// if (count > MAX_COUNT) {
-// flushStreams();
-// }
-
- MessageConsoleStream stream = console.newMessageStream();
- //viewer.setRedraw(false);
try {
+ flushStreams();
if (le.getLevel().isGreaterOrEqual(Level.WARN)) {
- stream.setColor(cachedRed);
+ redStream.println(labelProvider.getText(le));
+ } else {
+ blackStream.println(labelProvider.getText(le));
}
- stream.println(labelProvider.getText(le));
- stream.close();
} catch (Exception e) {
- //?
+ PluginLogger.logError(e);
}
- //viewer.revealRange(viewer.getBottomIndexEndOffset(), 1);
- revealEndOfDocument();
- //viewer.setRedraw(true);
- }
-
-// private void flushStreams() {
-// try {
-// blackStream.flush();
-// redStream.flush();
-// } catch (Exception e) {
-// PluginLogger.logError(e);
-// }
-// }
-
- private void revealEndOfDocument() {
revealJob.schedule(50);
}
-
+
+ private void flushStreams() {
+ try {
+ blackStream.flush();
+ redStream.flush();
+ } catch (Exception e) {
+ PluginLogger.logError(e);
+ }
+ }
+
public void setLabelProvider(LabelProvider provider) {
this.labelProvider = provider;
}
Modified: logbackPDE/trunk/plugins/ConsolePlugin/todo.txt
==============================================================================
--- logbackPDE/trunk/plugins/ConsolePlugin/todo.txt (original)
+++ logbackPDE/trunk/plugins/ConsolePlugin/todo.txt Fri Feb 23 18:10:27 2007
@@ -6,4 +6,6 @@
OK -> Make the viewer always display the latest lines added
-Is it possible to use the logger without bringing the ErrorLog view up?
\ No newline at end of file
+Is it possible to use the logger without bringing the ErrorLog view up?
+
+Allow the user to change the socket's port
\ No newline at end of file
More information about the logback-dev
mailing list