[java-opensaml COMMIT] /trunk/opensaml-profile-api/src/main/java/org/opensaml/profile/action/AbstractProfileAction.java

noreply at shibboleth.net noreply at shibboleth.net
Mon May 5 14:36:06 EDT 2014


Author: scantor
Date: Mon May  5 14:36:06 2014
New Revision: 3838

URL: http://svn.shibboleth.net/view/java-opensaml?rev=3838&view=rev
Log:
Improve logging.

Modified:
    trunk/opensaml-profile-api/src/main/java/org/opensaml/profile/action/AbstractProfileAction.java

Modified: trunk/opensaml-profile-api/src/main/java/org/opensaml/profile/action/AbstractProfileAction.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-profile-api/src/main/java/org/opensaml/profile/action/AbstractProfileAction.java?rev=3838&r1=3837&r2=3838&view=diff
==============================================================================
--- trunk/opensaml-profile-api/src/main/java/org/opensaml/profile/action/AbstractProfileAction.java (original)
+++ trunk/opensaml-profile-api/src/main/java/org/opensaml/profile/action/AbstractProfileAction.java Mon May  5 14:36:06 2014
@@ -46,6 +46,9 @@
 public abstract class AbstractProfileAction<InboundMessageType, OutboundMessageType>
         extends AbstractInitializableComponent implements ProfileAction<InboundMessageType, OutboundMessageType> {
 
+    /** Cached log prefix. */
+    @Nullable private String logPrefix;
+    
     /** Current HTTP request, if available. */
     @Nullable private HttpServletRequest httpServletRequest;
 
@@ -99,7 +102,7 @@
         // Clear any existing EventContext that might be hanging around, and if it exists,
         // copy the Event to a PreviousEventContext. Don't clear any existing PreviousEventContext
         // because it may be from an earlier error of interest to other actions.
-        EventContext previousEvent = profileRequestContext.getSubcontext(EventContext.class, false);
+        final EventContext<?> previousEvent = profileRequestContext.getSubcontext(EventContext.class);
         if (previousEvent != null) {
             profileRequestContext.getSubcontext(PreviousEventContext.class, true).setEvent(previousEvent.getEvent());
             profileRequestContext.removeSubcontext(EventContext.class);
@@ -214,7 +217,10 @@
      * @return a string for insertion at the beginning of any log messages
      */
     @Nonnull @NotEmpty protected String getLogPrefix() {
-        return "Profile Action:";
+        if (logPrefix == null) {
+            logPrefix = "Profile Action " + getClass().getSimpleName() + ":";
+        }
+        return logPrefix;
     }
 
 }



More information about the commits mailing list