directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r661328 - in /directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds: ./ actions/ jobs/
Date Thu, 29 May 2008 13:16:09 GMT
Author: pamarcelot
Date: Thu May 29 06:16:09 2008
New Revision: 661328

URL: http://svn.apache.org/viewvc?rev=661328&view=rev
Log:
Improved console logging.

Modified:
    directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/ApacheDsPluginUtils.java
    directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/ConsolesHandler.java
    directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/LogMessageConsole.java
    directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/StudioConsoleAppender.java
    directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/StopAction.java
    directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/jobs/LaunchServerJob.java

Modified: directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/ApacheDsPluginUtils.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/ApacheDsPluginUtils.java?rev=661328&r1=661327&r2=661328&view=diff
==============================================================================
--- directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/ApacheDsPluginUtils.java
(original)
+++ directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/ApacheDsPluginUtils.java
Thu May 29 06:16:09 2008
@@ -324,9 +324,7 @@
         sb.append( "log4j.rootCategory=ALL, studioConsoleAppender" ).append( "\n" );
         sb.append( "" ).append( "\n" );
         sb.append( "# Studio Console Appender (identified with the server id)" ).append(
"\n" );
-        sb
-            .append(
-                "log4j.appender.studioConsoleAppender=org.apache.directory.studio.apacheds.StudioConsoleAppender"
)
+        sb.append( "log4j.appender.studioConsoleAppender=org.apache.directory.studio.apacheds.StudioConsoleAppender"
)
             .append( "\n" );
         sb.append( "log4j.appender.studioConsoleAppender.ServerId=" ).append( id ).append(
"\n" );
         sb.append( "log4j.appender.studioConsoleAppender.layout=org.apache.log4j.PatternLayout"
).append( "\n" );

Modified: directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/ConsolesHandler.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/ConsolesHandler.java?rev=661328&r1=661327&r2=661328&view=diff
==============================================================================
--- directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/ConsolesHandler.java
(original)
+++ directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/ConsolesHandler.java
Thu May 29 06:16:09 2008
@@ -92,7 +92,7 @@
         {
             Server server = ServersHandler.getDefault().getServerById( serverId );
 
-            LogMessageConsole logMessageConsole = new LogMessageConsole( server.getName()
);
+            LogMessageConsole logMessageConsole = new LogMessageConsole( "Apache DS - " +
server.getName() );
 
             consolesMap.put( serverId, logMessageConsole );
 

Modified: directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/LogMessageConsole.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/LogMessageConsole.java?rev=661328&r1=661327&r2=661328&view=diff
==============================================================================
--- directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/LogMessageConsole.java
(original)
+++ directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/LogMessageConsole.java
Thu May 29 06:16:09 2008
@@ -32,7 +32,7 @@
 
 
 /**
- * TODO LogMessageConsole.
+ * A console that displays log messages.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
@@ -111,7 +111,8 @@
 
         // Setting the Color and Font settings
         setColorAndFontSettingsToMessageConsoleStream( debugMessageConsoleStream,
-            ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_DEBUG_COLOR, ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_DEBUG_FONT
);
+            ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_DEBUG_COLOR,
+            ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_DEBUG_FONT );
     }
 
 
@@ -142,7 +143,8 @@
 
         // Setting the Color and Font settings
         setColorAndFontSettingsToMessageConsoleStream( infoMessageConsoleStream,
-            ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_INFO_COLOR, ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_INFO_FONT
);
+            ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_INFO_COLOR,
+            ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_INFO_FONT );
     }
 
 
@@ -173,7 +175,8 @@
 
         // Setting the Color and Font settings
         setColorAndFontSettingsToMessageConsoleStream( warnMessageConsoleStream,
-            ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_WARN_COLOR, ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_WARN_FONT
);
+            ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_WARN_COLOR,
+            ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_WARN_FONT );
     }
 
 
@@ -204,7 +207,8 @@
 
         // Setting the Color and Font settings
         setColorAndFontSettingsToMessageConsoleStream( errorMessageConsoleStream,
-            ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_ERROR_COLOR, ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_ERROR_FONT
);
+            ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_ERROR_COLOR,
+            ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_ERROR_FONT );
     }
 
 
@@ -235,7 +239,8 @@
 
         // Setting the Color and Font settings
         setColorAndFontSettingsToMessageConsoleStream( fatalMessageConsoleStream,
-            ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_FATAL_COLOR, ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_FATAL_FONT
);
+            ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_FATAL_COLOR,
+            ApacheDsPluginConstants.PREFS_COLORS_AND_FONTS_FATAL_FONT );
     }
 
 

Modified: directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/StudioConsoleAppender.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/StudioConsoleAppender.java?rev=661328&r1=661327&r2=661328&view=diff
==============================================================================
--- directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/StudioConsoleAppender.java
(original)
+++ directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/StudioConsoleAppender.java
Thu May 29 06:16:09 2008
@@ -23,6 +23,7 @@
 import org.apache.log4j.Appender;
 import org.apache.log4j.AppenderSkeleton;
 import org.apache.log4j.Level;
+import org.apache.log4j.PatternLayout;
 import org.apache.log4j.spi.LoggingEvent;
 
 
@@ -43,6 +44,8 @@
      */
     public StudioConsoleAppender()
     {
+        super();
+        setLayout( new PatternLayout( "[%d{HH:mm:ss}] %p [%c] - %m%n" ) );
     }
 
 
@@ -52,29 +55,33 @@
     protected void append( LoggingEvent event )
     {
         LogMessageConsole console = ConsolesHandler.getDefault().getLogMessageConsole( serverId
);
-
-        Level level = event.getLevel();
-        Object message = event.getMessage();
-
-        if ( level == Level.INFO )
-        {
-            console.getInfoConsoleMessageStream().println( message.toString() );
-        }
-        else if ( level == Level.DEBUG )
-        {
-            console.getDebugConsoleMessageStream().println( message.toString() );
-        }
-        else if ( level == Level.WARN )
+        if ( console != null )
         {
-            console.getWarnConsoleMessageStream().println( message.toString() );
-        }
-        else if ( level == Level.ERROR )
-        {
-            console.getErrorConsoleMessageStream().println( message.toString() );
-        }
-        else if ( level == Level.FATAL )
-        {
-            console.getFatalConsoleMessageStream().println( message.toString() );
+            // Formatting the message with the layout
+            String message = layout.format( 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 )
+            {
+                console.getFatalConsoleMessageStream().print( message );
+            }
         }
     }
 

Modified: directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/StopAction.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/StopAction.java?rev=661328&r1=661327&r2=661328&view=diff
==============================================================================
--- directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/StopAction.java
(original)
+++ directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/actions/StopAction.java
Thu May 29 06:16:09 2008
@@ -20,8 +20,12 @@
 package org.apache.directory.studio.apacheds.actions;
 
 
+import java.io.IOException;
+
 import org.apache.directory.studio.apacheds.ApacheDsPlugin;
 import org.apache.directory.studio.apacheds.ApacheDsPluginConstants;
+import org.apache.directory.studio.apacheds.ConsolesHandler;
+import org.apache.directory.studio.apacheds.LogMessageConsole;
 import org.apache.directory.studio.apacheds.jobs.LaunchServerJob;
 import org.apache.directory.studio.apacheds.model.Server;
 import org.apache.directory.studio.apacheds.model.ServerStateEnum;
@@ -32,6 +36,7 @@
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
 
@@ -47,6 +52,9 @@
     /** The associated view */
     private ServersView view;
 
+    /** The server */
+    private Server server;
+
 
     /**
      * Creates a new instance of StopAction.
@@ -72,7 +80,7 @@
         if ( ( !selection.isEmpty() ) && ( selection.size() == 1 ) )
         {
             // Getting the server
-            Server server = ( Server ) selection.getFirstElement();
+            server = ( Server ) selection.getFirstElement();
 
             // Setting the server of the server to 'stopping'
             server.setState( ServerStateEnum.STOPPING );
@@ -89,6 +97,7 @@
                     try
                     {
                         launch.terminate();
+                        writeToInfoConsoleMessageStream( "Server stopped.\n" );
                     }
                     catch ( DebugException e )
                     {
@@ -101,6 +110,33 @@
     }
 
 
+    /**
+     * Writes the given message to the Info console message stream.
+     *
+     * @param message
+     *      the message
+     */
+    private void writeToInfoConsoleMessageStream( final String message )
+    {
+        Display.getDefault().asyncExec( new Runnable()
+        {
+            public void run()
+            {
+                LogMessageConsole console = ConsolesHandler.getDefault().getLogMessageConsole(
server.getId() );
+                try
+                {
+                    console.getInfoConsoleMessageStream().write( message );
+                }
+                catch ( IOException e )
+                {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                }
+            }
+        } );
+    }
+
+
     /* (non-Javadoc)
      * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
      */

Modified: directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/jobs/LaunchServerJob.java
URL: http://svn.apache.org/viewvc/directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/jobs/LaunchServerJob.java?rev=661328&r1=661327&r2=661328&view=diff
==============================================================================
--- directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/jobs/LaunchServerJob.java
(original)
+++ directory/studio/branches/apacheds-plugin-branch/apacheds/src/main/java/org/apache/directory/studio/apacheds/jobs/LaunchServerJob.java
Thu May 29 06:16:09 2008
@@ -111,23 +111,7 @@
 
         // Setting the server in a "starting" state
         server.setState( ServerStateEnum.STARTING );
-
-        Display.getDefault().asyncExec( new Runnable()
-        {
-            public void run()
-            {
-                LogMessageConsole console = ConsolesHandler.getDefault().getLogMessageConsole(
server.getId() );
-                try
-                {
-                    console.getInfoConsoleMessageStream().write( "Starting " + server.getName()
+ "...\n" );
-                }
-                catch ( IOException e )
-                {
-                    // TODO Auto-generated catch block
-                    e.printStackTrace();
-                }
-            }
-        } );
+        writeToInfoConsoleMessageStream( "Server starting...\n" );
 
         // Getting the first available port for the Log4J socket server
         int port = AvailablePortFinder.getNextAvailable( MIN_PORT );
@@ -188,6 +172,7 @@
 
                         // We set the state of the server to 'started'...
                         server.setState( ServerStateEnum.STARTED );
+                        writeToInfoConsoleMessageStream( "Server started.\n" );
 
                         /// ... and we exit the thread
                         return;
@@ -214,6 +199,7 @@
                 if ( ServerStateEnum.STARTING == server.getState() )
                 {
                     server.setState( ServerStateEnum.STOPPED );
+                    writeToInfoConsoleMessageStream( "Server stopped.\n" );
                 }
             }
 
@@ -242,6 +228,33 @@
 
 
     /**
+     * Writes the given message to the Info console message stream.
+     *
+     * @param message
+     *      the message
+     */
+    private void writeToInfoConsoleMessageStream( final String message )
+    {
+        Display.getDefault().asyncExec( new Runnable()
+        {
+            public void run()
+            {
+                LogMessageConsole console = ConsolesHandler.getDefault().getLogMessageConsole(
server.getId() );
+                try
+                {
+                    console.getInfoConsoleMessageStream().write( message );
+                }
+                catch ( IOException e )
+                {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                }
+            }
+        } );
+    }
+
+
+    /**
      * Starting the "terminate" listener thread.
      */
     private void startTerminateListenerThread()
@@ -340,8 +353,7 @@
      */
     private void overwriteServersLog4jPropertiesFile( int port ) throws IOException
     {
-        IPath confFolderPath = ApacheDsPluginUtils.getApacheDsServersFolder().append( server.getId()
)
-            .append( "conf" );
+        IPath confFolderPath = ApacheDsPluginUtils.getApacheDsServersFolder().append( server.getId()
).append( "conf" );
         File confFolder = new File( confFolderPath.toOSString() );
         ApacheDsPluginUtils.createServersLog4jPropertiesFile( new FileOutputStream( new File(
confFolder,
             "log4j.properties" ) ), port );



Mime
View raw message