geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r669868 - /geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommand.java
Date Fri, 20 Jun 2008 12:01:15 GMT
Author: jdillon
Date: Fri Jun 20 05:01:15 2008
New Revision: 669868

URL: http://svn.apache.org/viewvc?rev=669868&view=rev
Log:
Install commandId into the MDC for logging context

Modified:
    geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommand.java

Modified: geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommand.java?rev=669868&r1=669867&r2=669868&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommand.java
(original)
+++ geronimo/gshell/trunk/gshell-rapture/src/main/java/org/apache/geronimo/gshell/rapture/DefaultCommand.java
Fri Jun 20 05:01:15 2008
@@ -41,6 +41,7 @@
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
 
 /**
  * The default {@link Command} component.
@@ -115,20 +116,23 @@
 
         CommandAction action = getAction();
 
-        // TODO: Handle logging muck
-        // NOTE: For logging, just set the NDC/MDC and let the loggers name be whatever the
command set it to be.
-        
-        // TODO: Bind context, io and variables
-        // NOTE: No, no no...
+        MDC.put("commandId", commandId);
 
-        // Process command line options/arguments, return if we have been asked to display
--help
-        if (processArguments(context, action, context.getArguments())) {
-            return CommandAction.Result.SUCCESS;
-        }
+        Object result;
 
-        Object result = action.execute(context);
+        try {
+            // Process command line options/arguments, return if we have been asked to display
--help
+            if (processArguments(context, action, context.getArguments())) {
+                return CommandAction.Result.SUCCESS;
+            }
 
-        log.trace("Result: {}", result);
+            result = action.execute(context);
+
+            log.trace("Result: {}", result);
+        }
+        finally {
+            MDC.remove("commandId");
+        }
 
         return result;
     }



Mime
View raw message