directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r825509 - /directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/StudioConsoleAppender.java
Date Thu, 15 Oct 2009 14:55:09 GMT
Author: pamarcelot
Date: Thu Oct 15 14:55:09 2009
New Revision: 825509

URL: http://svn.apache.org/viewvc?rev=825509&view=rev
Log:
DIRSTUDIO-569 ( Exceptions showing up in the log when starting a server in the Apache DS plugin).

Modified:
    directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/StudioConsoleAppender.java

Modified: directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/StudioConsoleAppender.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/StudioConsoleAppender.java?rev=825509&r1=825508&r2=825509&view=diff
==============================================================================
--- directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/StudioConsoleAppender.java
(original)
+++ directory/studio/trunk/apacheds/src/main/java/org/apache/directory/studio/apacheds/StudioConsoleAppender.java
Thu Oct 15 14:55:09 2009
@@ -81,35 +81,44 @@
      */
     protected void append( LoggingEvent event )
     {
-        LogMessageConsole console = ConsolesHandler.getDefault().getLogMessageConsole( serverId
);
-        if ( console != null )
-        {
-            // Formatting the message with the layout
-            String message = layout.format( event );
+        final LoggingEvent logEvent = event;
 
-            // Switching dependening on the level
-            Level level = event.getLevel();
-            if ( level == Level.INFO )
-            {
-                console.getInfoConsoleMessageStream().print( message );
-            }
-            else if ( level == Level.DEBUG )
-            {
-                console.getDebugConsoleMessageStream().print( message );
-            }
-            else if ( level == Level.WARN )
-            {
-                console.getWarnConsoleMessageStream().print( message );
-            }
-            else if ( level == Level.ERROR )
-            {
-                console.getErrorConsoleMessageStream().print( message );
-            }
-            else if ( level == Level.FATAL )
+        // We need to print the message on console asynchronously to avoid UI thread exception
+        Display.getDefault().asyncExec( new Runnable()
+        {
+            public void run()
             {
-                console.getFatalConsoleMessageStream().print( message );
+                LogMessageConsole console = ConsolesHandler.getDefault().getLogMessageConsole(
serverId );
+                if ( console != null )
+                {
+                    // Formatting the message with the layout
+                    String message = layout.format( logEvent );
+
+                    // Switching dependening on the level
+                    Level level = logEvent.getLevel();
+                    if ( level == Level.INFO )
+                    {
+                        console.getInfoConsoleMessageStream().print( message );
+                    }
+                    else if ( level == Level.DEBUG )
+                    {
+                        console.getDebugConsoleMessageStream().print( message );
+                    }
+                    else if ( level == Level.WARN )
+                    {
+                        console.getWarnConsoleMessageStream().print( message );
+                    }
+                    else if ( level == Level.ERROR )
+                    {
+                        console.getErrorConsoleMessageStream().print( message );
+                    }
+                    else if ( level == Level.FATAL )
+                    {
+                        console.getFatalConsoleMessageStream().print( message );
+                    }
+                }
             }
-        }
+        } );
     }
 
 



Mime
View raw message