You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by an...@apache.org on 2005/08/31 04:20:49 UTC

svn commit: r264923 - in /cocoon/trunk: src/java/org/apache/cocoon/util/log/CocoonLogFormatter.java status.xml

Author: antonio
Date: Tue Aug 30 19:20:43 2005
New Revision: 264923

URL: http://svn.apache.org/viewcvs?rev=264923&view=rev
Log:
Fix 36373: getTime(...) of CocoonLogFormatter implemented incorrectly
Thanks to Johan Stuyts (j.stuyts@hippo.nl)

Modified:
    cocoon/trunk/src/java/org/apache/cocoon/util/log/CocoonLogFormatter.java
    cocoon/trunk/status.xml

Modified: cocoon/trunk/src/java/org/apache/cocoon/util/log/CocoonLogFormatter.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/util/log/CocoonLogFormatter.java?rev=264923&r1=264922&r2=264923&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/util/log/CocoonLogFormatter.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/util/log/CocoonLogFormatter.java Tue Aug 30 19:20:43 2005
@@ -23,12 +23,11 @@
 import org.apache.cocoon.util.ExceptionUtils;
 
 import org.apache.commons.lang.ClassUtils;
+import org.apache.commons.lang.time.FastDateFormat;
 import org.apache.log.ContextMap;
 import org.apache.log.LogEvent;
 import org.apache.log.Logger;
 
-import java.text.SimpleDateFormat;
-import java.util.Date;
 import java.util.Map;
 
 /**
@@ -76,7 +75,7 @@
     protected final static String  TYPE_QUERY_STR       = "query";
     protected final static String  TYPE_ROOTTHROWABLE_STR = "rootThrowable";
 
-    protected final static SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("(yyyy-MM-dd) HH:mm.ss:SSS");
+    private static final String DEFAULT_TIME_PATTERN = "(yyyy-MM-dd) HH:mm.ss:SSS";
 
     /**
      * Hack to get the call stack as an array of classes. The
@@ -230,8 +229,7 @@
             final Object context = ctxMap.get("objectModel");
             if (context != null && context instanceof Map) {
                 // Get the request
-                final Request request = ObjectModelHelper
-                        .getRequest((Map) context);
+                final Request request = ObjectModelHelper.getRequest((Map) context);
                 if (request != null) {
                     final String queryString = request.getQueryString();
                     if (queryString != null) {
@@ -300,10 +298,17 @@
      * Utility method to format time.
      *
      * @param time the time
-     * @param format ancilliary format parameter - allowed to be null
+     * @param pattern ancilliary pattern parameter - allowed to be null
      * @return the formatted string
      */
-    protected String getTime(final long time, final String format) {
-        return DATE_FORMATTER.format(new Date());
+    protected String getTime(final long time, String pattern) {
+        String result;
+
+        if (pattern == null) {
+            pattern = DEFAULT_TIME_PATTERN;
+        }
+        FastDateFormat format = FastDateFormat.getInstance(pattern);
+        result = format.format(time);
+        return result;
     }
 }

Modified: cocoon/trunk/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/status.xml?rev=264923&r1=264922&r2=264923&view=diff
==============================================================================
--- cocoon/trunk/status.xml (original)
+++ cocoon/trunk/status.xml Tue Aug 30 19:20:43 2005
@@ -530,6 +530,9 @@
    </action>
   </release>
   <release version="2.1.8" date="TBD">
+    <action dev="AG" type="fix" fixes-bug="36373" due-to="Johan Stuyts" due-to-email="j.stuyts@hippo.nl">
+      getTime(...) of CocoonLogFormatter implemented incorrectly
+    </action>
     <action dev="VG" type="update">
       SourceWritingTransformer supports all allowed nodes when using
       <code>source:write</code> to create new document.



Re: svn commit: r264923 - in /cocoon/trunk: src/java/org/apache/cocoon/util/log/CocoonLogFormatter.java status.xml

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Antonio Gallardo wrote:
> 
> See: http://svn.apache.org/viewcvs?rev=266246&view=rev
> 
> Is this what you have in mind? ;-)

Yep, much better :)

Vadim


> Best Regards,
> 
> Antonio Gallardo
> 
> Vadim Gritsenko wrote:
> 
>> antonio@apache.org wrote:
>>
>>> -    protected final static SimpleDateFormat DATE_FORMATTER = new 
>>> SimpleDateFormat("(yyyy-MM-dd) HH:mm.ss:SSS");
>>> +    private static final String DEFAULT_TIME_PATTERN = "(yyyy-MM-dd) 
>>> HH:mm.ss:SSS";
>>
>>
>> Antonio,
>>
>> According to [1]:
>>
>>     FastDateFormat is a fast and thread-safe version of SimpleDateFormat.
>>
>> So I suggest revisiting this piece of code in order to improve 
>> efficiency :-)
>>
>> Thanks,
>> Vadim
>>
>> [1] 
>> http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/time/FastDateFormat.html 


Re: svn commit: r264923 - in /cocoon/trunk: src/java/org/apache/cocoon/util/log/CocoonLogFormatter.java status.xml

Posted by Antonio Gallardo <ag...@agssa.net>.
See: http://svn.apache.org/viewcvs?rev=266246&view=rev

Is this what you have in mind? ;-)

Best Regards,

Antonio Gallardo

Vadim Gritsenko wrote:

> antonio@apache.org wrote:
>
>> -    protected final static SimpleDateFormat DATE_FORMATTER = new 
>> SimpleDateFormat("(yyyy-MM-dd) HH:mm.ss:SSS");
>> +    private static final String DEFAULT_TIME_PATTERN = "(yyyy-MM-dd) 
>> HH:mm.ss:SSS";
>
>
> Antonio,
>
> According to [1]:
>
>     FastDateFormat is a fast and thread-safe version of SimpleDateFormat.
>
> So I suggest revisiting this piece of code in order to improve 
> efficiency :-)
>
> Thanks,
> Vadim
>
> [1] 
> http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/time/FastDateFormat.html 
>



Re: svn commit: r264923 - in /cocoon/trunk: src/java/org/apache/cocoon/util/log/CocoonLogFormatter.java status.xml

Posted by Antonio Gallardo <ag...@agssa.net>.
Vadim Gritsenko wrote:

> antonio@apache.org wrote:
>
>> -    protected final static SimpleDateFormat DATE_FORMATTER = new 
>> SimpleDateFormat("(yyyy-MM-dd) HH:mm.ss:SSS");
>> +    private static final String DEFAULT_TIME_PATTERN = "(yyyy-MM-dd) 
>> HH:mm.ss:SSS";
>
>
> Antonio,
>
> According to [1]:
>
>     FastDateFormat is a fast and thread-safe version of SimpleDateFormat.
>
> So I suggest revisiting this piece of code in order to improve 
> efficiency :-)


You are right! I will fix this today after work. :-)

Best Regards,

Antonio Gallardo

>
>
> [1] 
> http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/time/FastDateFormat.html 
>



Re: svn commit: r264923 - in /cocoon/trunk: src/java/org/apache/cocoon/util/log/CocoonLogFormatter.java status.xml

Posted by Vadim Gritsenko <va...@reverycodes.com>.
antonio@apache.org wrote:
> -    protected final static SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("(yyyy-MM-dd) HH:mm.ss:SSS");
> +    private static final String DEFAULT_TIME_PATTERN = "(yyyy-MM-dd) HH:mm.ss:SSS";

Antonio,

According to [1]:

     FastDateFormat is a fast and thread-safe version of SimpleDateFormat.

So I suggest revisiting this piece of code in order to improve efficiency :-)

Thanks,
Vadim

[1] 
http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/time/FastDateFormat.html