Changeset 1577

Show
Ignore:
Timestamp:
12/07/09 15:44:44 (2 years ago)
Author:
amandel
Message:

Allow to add context parameters to the log records via LogThreadContext?.
The parameters are added as logging parameters with a CTX~ prefix.

Location:
trunk
Files:
1 added
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/config/build-test.xml

    r1356 r1577  
    212212            depends="test-compile, instrument, test-single-local-nodeps" 
    213213            description="Run a single JUnit test suite"/> 
    214     <target name="test-single-local-nodeps" if="testcase, junit.present"> 
     214    <target name="test-single-local-nodeps" if="testcase"> 
    215215        <mkdir dir="${build.dir}/report/junit"/> 
    216216        <junit printsummary="yes" haltonfailure="no" 
     
    221221            <sysproperty key="basedir" value="${base.dir}"/> 
    222222            <sysproperty key="java.util.logging.config.file" 
    223                     value="${base.dir}/src/etc/fawkez-logging.properties"/> 
     223                    file="${base.dir}/src/etc/fawkez-logging.properties"/> 
    224224            <sysproperty key="org.xml.sax.driver" 
    225225                    value="org.apache.xerces.parsers.SAXParser"/> 
  • trunk/src/java/org/jcoderz/commons/LogFormatter.java

    r1535 r1577  
    121121    * @param sb the StringBuffer where to append the formatted log record 
    122122    * @param record the log record to format 
    123     * @param trackingIdSequence a list collectiong all tracking ids of messages 
     123    * @param trackingIdSequence a list collecting all tracking ids of messages 
    124124    * being formatted by one call. 
    125125    */ 
  • trunk/src/java/org/jcoderz/commons/LoggableImpl.java

    r1535 r1577  
    4646import java.util.Random; 
    4747import java.util.Set; 
     48import java.util.Map.Entry; 
    4849import java.util.logging.Logger; 
    4950 
     
    126127   public static final String GROUP_NAME_PARAMETER_NAME = "_GROUP"; 
    127128 
     129   /** Context parameter values prefix. */ 
     130   public static final String CONTEXT_PARAMETER_PREFIX = "CTX~"; 
     131    
    128132   /** This nodes id. */ 
    129133   public static final String NODE_ID = getStaticNodeId(); 
     
    256260      mOuter = outer; 
    257261      initInternalParameters(); 
     262      initThreadContextParameters(); 
    258263   } 
    259264 
     
    301306      initCause(cause); 
    302307      initInternalParameters(); 
     308      initThreadContextParameters(); 
    303309   } 
    304310 
     
    513519   } 
    514520 
     521   private final void initThreadContextParameters () 
     522   { 
     523       final Iterator i = LogThreadContext.get().entrySet().iterator(); 
     524       while (i.hasNext()) 
     525       { 
     526           final Entry entry = (Entry) i.next(); 
     527           addParameter( 
     528               CONTEXT_PARAMETER_PREFIX + entry.getKey(),  
     529               String.valueOf(entry.getValue())); 
     530       } 
     531   } 
     532    
    515533   private final void getSource () 
    516534   {