You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by na...@apache.org on 2008/11/13 23:13:25 UTC

svn commit: r713841 [1/5] - in /webservices/axis/trunk/c/src: cbindings/ common/ engine/ engine/client/ engine/server/ platforms/aix/ platforms/hp-ux/ platforms/os400/ platforms/unix/ platforms/windows/ server/simple_axis_server/ soap/ transport/ trans...

Author: nadiramra
Date: Thu Nov 13 14:13:23 2008
New Revision: 713841

URL: http://svn.apache.org/viewvc?rev=713841&view=rev
Log:
AXISCPP-100 enable axis c++ (engine) tracing

Modified:
    webservices/axis/trunk/c/src/cbindings/AxisC.cpp
    webservices/axis/trunk/c/src/common/ArrayBean.cpp
    webservices/axis/trunk/c/src/common/AxisCPPConfigDefaultsImpl.cpp
    webservices/axis/trunk/c/src/common/AxisConfig.cpp
    webservices/axis/trunk/c/src/common/AxisConfig.h
    webservices/axis/trunk/c/src/common/AxisTrace.cpp
    webservices/axis/trunk/c/src/common/AxisTrace.h
    webservices/axis/trunk/c/src/common/AxisUtils.cpp
    webservices/axis/trunk/c/src/common/BasicTypeSerializer.cpp
    webservices/axis/trunk/c/src/common/MessageData.cpp
    webservices/axis/trunk/c/src/common/Param.cpp
    webservices/axis/trunk/c/src/engine/AppScopeHandlerPool.cpp
    webservices/axis/trunk/c/src/engine/Axis.cpp
    webservices/axis/trunk/c/src/engine/AxisEngine.cpp
    webservices/axis/trunk/c/src/engine/DeserializerPool.cpp
    webservices/axis/trunk/c/src/engine/HandlerChain.cpp
    webservices/axis/trunk/c/src/engine/HandlerLoader.cpp
    webservices/axis/trunk/c/src/engine/HandlerPool.cpp
    webservices/axis/trunk/c/src/engine/RequestScopeHandlerPool.cpp
    webservices/axis/trunk/c/src/engine/SOAPTransportFactory.cpp
    webservices/axis/trunk/c/src/engine/SOAPTransportFactory.h
    webservices/axis/trunk/c/src/engine/SerializerPool.cpp
    webservices/axis/trunk/c/src/engine/SessionScopeHandlerPool.cpp
    webservices/axis/trunk/c/src/engine/XMLParserFactory.cpp
    webservices/axis/trunk/c/src/engine/XMLParserFactory.h
    webservices/axis/trunk/c/src/engine/client/Call.cpp
    webservices/axis/trunk/c/src/engine/client/ClientAxisEngine.cpp
    webservices/axis/trunk/c/src/engine/client/Stub.cpp
    webservices/axis/trunk/c/src/engine/server/ServerAxisEngine.cpp
    webservices/axis/trunk/c/src/platforms/aix/PlatformSpecificAIX.hpp
    webservices/axis/trunk/c/src/platforms/hp-ux/PlatformSpecificHP-UX.hpp
    webservices/axis/trunk/c/src/platforms/os400/PlatformSpecificOS400.hpp
    webservices/axis/trunk/c/src/platforms/unix/PlatformSpecificUnix.hpp
    webservices/axis/trunk/c/src/platforms/windows/PlatformSpecificWindows.hpp
    webservices/axis/trunk/c/src/server/simple_axis_server/SimpleAxisServer.cpp
    webservices/axis/trunk/c/src/soap/HeaderBlock.cpp
    webservices/axis/trunk/c/src/soap/SoapBody.cpp
    webservices/axis/trunk/c/src/soap/SoapDeSerializer.cpp
    webservices/axis/trunk/c/src/soap/SoapEnvelope.cpp
    webservices/axis/trunk/c/src/soap/SoapFault.cpp
    webservices/axis/trunk/c/src/soap/SoapHeader.cpp
    webservices/axis/trunk/c/src/soap/SoapMethod.cpp
    webservices/axis/trunk/c/src/soap/SoapSerializer.cpp
    webservices/axis/trunk/c/src/transport/SOAPTransport.h
    webservices/axis/trunk/c/src/transport/axis3/ChannelFactory.cpp
    webservices/axis/trunk/c/src/transport/axis3/HTTPChannel/HTTPChannel.cpp
    webservices/axis/trunk/c/src/transport/axis3/HTTPChannel/HTTPChannel.hpp
    webservices/axis/trunk/c/src/transport/axis3/HTTPChannel/HTTPChannelInstantiator.cpp
    webservices/axis/trunk/c/src/transport/axis3/HTTPSSLChannel/HTTPSSLChannelInstantiator.cpp
    webservices/axis/trunk/c/src/transport/axis3/HTTPTransport.cpp
    webservices/axis/trunk/c/src/transport/axis3/HTTPTransport.hpp
    webservices/axis/trunk/c/src/transport/axis3/HTTPTransportInstantiator.cpp
    webservices/axis/trunk/c/src/transport/axis3/IChannel.hpp
    webservices/axis/trunk/c/src/wsdd/WSDDDeployment.cpp
    webservices/axis/trunk/c/src/wsdd/WSDDDocument.cpp
    webservices/axis/trunk/c/src/xml/XMLParser.h
    webservices/axis/trunk/c/src/xml/xerces/ParserLoader.cpp
    webservices/axis/trunk/c/src/xml/xerces/XMLParserXerces.cpp
    webservices/axis/trunk/c/src/xml/xerces/XMLParserXerces.h

Modified: webservices/axis/trunk/c/src/cbindings/AxisC.cpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/cbindings/AxisC.cpp?rev=713841&r1=713840&r2=713841&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/cbindings/AxisC.cpp (original)
+++ webservices/axis/trunk/c/src/cbindings/AxisC.cpp Thu Nov 13 14:13:23 2008
@@ -18,6 +18,9 @@
 // !!! This include file must be first thing in file !!!
 #include "../platforms/PlatformAutoSense.hpp"
 
+#include <stdarg.h>
+#include <string>
+
 #include <iostream>
 
 #include <axis/ElementMissingException.hpp>
@@ -488,5 +491,40 @@
 	throw UnknownElementException(s);
 }
 
+AXISC_STORAGE_CLASS_INFO
+int axiscAxisStartTrace(const char* logFilePath, const char *logFilter)
+{
+	return Axis::startTrace(logFilePath, logFilter);
+}
+
+AXISC_STORAGE_CLASS_INFO
+void axiscAxisStopTrace()
+{
+	Axis::stopTrace();
+}
+
+AXISC_STORAGE_CLASS_INFO
+void axiscAxisWriteTrace(const char* functionName, const char * fmt, ...)
+{
+	// If logging is not enabled, just return.
+	if (!AxisTrace::isLoggingEnabled() || !AxisTrace::isStubLoggingEnabled())
+		return;
+	
+    // Construct final formatter
+    std::string myfmt;
+    std::string blank = " ";
+    if (NULL == fmt)
+        fmt = "";
+    myfmt += TRACE_COMPONENT_STUB + blank;
+    myfmt += TRACE_TYPE_DEBUG + blank;
+    myfmt += functionName;
+    myfmt += "(): ";
+    myfmt += fmt;
+        
+    va_list vargs;
+    va_start(vargs,fmt);
+    AxisTrace::writeTrace(myfmt.c_str(), vargs);        
+    va_end(vargs);
+}
 
 }
\ No newline at end of file

Modified: webservices/axis/trunk/c/src/common/ArrayBean.cpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/common/ArrayBean.cpp?rev=713841&r1=713840&r2=713841&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/common/ArrayBean.cpp (original)
+++ webservices/axis/trunk/c/src/common/ArrayBean.cpp Thu Nov 13 14:13:23 2008
@@ -35,15 +35,23 @@
 
 AXIS_CPP_NAMESPACE_START
 
-ArrayBean::ArrayBean()
+ArrayBean::
+ArrayBean()
 {
+	logEntryEngine("ArrayBean::ArrayBean")
+	
     m_type = XSD_UNKNOWN;
     m_ItemName = "";
     m_value.sta = NULL;
+    
+    logExit()
 }
 
-ArrayBean::~ArrayBean()
+ArrayBean::
+~ArrayBean()
 {
+	logEntryEngine("ArrayBean::~ArrayBean")
+
     if (USER_TYPE == m_type)
     {
         if (m_value.cta)
@@ -52,9 +60,11 @@
             {
                 if (AxisEngine::m_bServer)
                 {
-					TRACE_OBJECT_DELETE_FUNCT_ENTRY(m_value.cta->pDelFunct, m_value.cta->pObject,  m_nSize);
+                    logDebugArg2("Calling object delete function %p for object %p", m_value.cta->pDelFunct, m_value.cta->pObject)
+                    
                     m_value.cta->pDelFunct(m_value.cta->pObject, m_nSize);
-					TRACE_OBJECT_DELETE_FUNCT_EXIT(m_value.cta->pDelFunct);
+                    
+                    logDebugArg1("Returned from object delete function %p", m_value.cta->pDelFunct)
                 }
                 // make sure that the ComplexObjectHandler's destructor does 
                 // not try to delete the objects again 
@@ -74,15 +84,21 @@
         }
         delete [] m_value.sta;
     }
+	
+	logExit()
 }
 
-int ArrayBean::GetArraySize()
+int ArrayBean::
+GetArraySize()
 {	
     return m_nSize;
 }
 
-int ArrayBean::Serialize(SoapSerializer& pSZ)
+int ArrayBean::
+Serialize(SoapSerializer& pSZ)
 {	
+	logEntryEngine("ArrayBean::Serialize")
+
     if (USER_TYPE == m_type)
     {
         void* pItem;
@@ -121,10 +137,12 @@
                 // note : ">" is not serialized to enable the type's serializer
                 // to add attributes 
 
-				TRACE_SERIALIZE_FUNCT_ENTRY(m_value.cta->pSZFunct, pItem, &pSZ, true);
+                logDebugArg2("Calling object serializer function %p for object %p", m_value.cta->pSZFunct, pItem)
+
                 int stat = AXIS_FAIL;
                 stat = m_value.cta->pSZFunct(pItem, &pSZ, true); 
-				TRACE_SERIALIZE_FUNCT_EXIT(m_value.cta->pSZFunct, stat);
+                
+                logDebugArg2("Returned from calling object serializer function %p, status %d", m_value.cta->pSZFunct, stat)
 
                 // no matter true or false is passed
             	if (pPrefix != NULL)
@@ -148,10 +166,12 @@
             {
                 pItem = ptrval[x];
 
-				TRACE_SERIALIZE_FUNCT_ENTRY(m_value.cta->pSZFunct, pItem, &pSZ, true);
+                logDebugArg2("Calling object serializer function %p for object %p", m_value.cta->pSZFunct, pItem)
+
                 int stat = AXIS_FAIL;
-                stat = m_value.cta->pSZFunct(pItem, &pSZ, true); 
-				TRACE_SERIALIZE_FUNCT_EXIT(m_value.cta->pSZFunct, stat);
+                stat = m_value.cta->pSZFunct(pItem, &pSZ, true);
+                
+                logDebugArg2("Returned from calling object serializer function %p, status %d", m_value.cta->pSZFunct, stat)
             }
         }
     }
@@ -163,7 +183,8 @@
  
 	   	const AxisChar* pNamespace = pSZ.getNamespace();
        	        
-       	if (RPC_ENCODED == nStyle) pSZ.setStyle(RPC_LITERAL); 
+       	if (RPC_ENCODED == nStyle) 
+       		pSZ.setStyle(RPC_LITERAL); 
 
         void ** p = (void **) m_value.sta;
         for (int ix = 0 ; ix < m_nSize ; ix++ )
@@ -172,27 +193,35 @@
         }
 
     	// restore Serializer's style after array serialization is finished
-    	if (RPC_ENCODED == nStyle) pSZ.setStyle(RPC_ENCODED);
+    	if (RPC_ENCODED == nStyle) 
+    		pSZ.setStyle(RPC_ENCODED);
     }
+	
+	logExitWithReturnCode(AXIS_SUCCESS)
+	
     return AXIS_SUCCESS;
 }
 
-void ArrayBean::SetDimension(int nDim)
+void ArrayBean::
+SetDimension(int nDim)
 {
     m_nSize = nDim;
 }
 
-void ArrayBean::SetItemName(const AxisChar* sName)
+void ArrayBean::
+SetItemName(const AxisChar* sName)
 {
     m_ItemName = sName;
 }
 
-void ArrayBean::SetTypeName(const AxisChar* sName)
+void ArrayBean::
+SetTypeName(const AxisChar* sName)
 {
     m_TypeName = sName;
 }
 
-void ArrayBean::SetUri(const AxisChar* sURI)
+void ArrayBean::
+SetUri(const AxisChar* sURI)
 {
     if (sURI)
         m_URI = sURI;
@@ -203,19 +232,20 @@
  * by the destructor.
  */
 
-void ArrayBean::RemoveArrayPointer()
+void ArrayBean::
+RemoveArrayPointer()
 {
+	logEntryEngine("ArrayBean::RemoveArrayPointer")
+
     if (USER_TYPE == m_type)
     {
         if (m_value.cta)
-        {
             m_value.cta->pObject = NULL;	
-        }
     }
     else
-    {
         m_value.sta = NULL;
-    }
+	
+	logExit()
 }
 
 AXIS_CPP_NAMESPACE_END

Modified: webservices/axis/trunk/c/src/common/AxisCPPConfigDefaultsImpl.cpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/common/AxisCPPConfigDefaultsImpl.cpp?rev=713841&r1=713840&r2=713841&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/common/AxisCPPConfigDefaultsImpl.cpp (original)
+++ webservices/axis/trunk/c/src/common/AxisCPPConfigDefaultsImpl.cpp Thu Nov 13 14:13:23 2008
@@ -106,7 +106,6 @@
   }
   else
   {
-      AXISTRACE1 ("configuration defaults aleady set", WARN);
       throw AxisConfigException(CONFIG_DEFAULTS_ALREADY_SET);
   }
 }
@@ -204,7 +203,4 @@
     return (char*)(m_pcAxisHome.c_str());
 }
 
-/** /todo place some sample code here
-*/
-
 AXIS_CPP_NAMESPACE_END

Modified: webservices/axis/trunk/c/src/common/AxisConfig.cpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/common/AxisConfig.cpp?rev=713841&r1=713840&r2=713841&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/common/AxisConfig.cpp (original)
+++ webservices/axis/trunk/c/src/common/AxisConfig.cpp Thu Nov 13 14:13:23 2008
@@ -39,12 +39,15 @@
 
 AXIS_CPP_NAMESPACE_START 
 
-AxisConfig::AxisConfig()
+AxisConfig::
+AxisConfig()
 {
     m_pcKeyArray[AXCONF_WSDDFILEPATH]       = AXCONF_WSDDFILEPATH_TAGNAME;
     m_pcKeyArray[AXCONF_LOGPATH]            = AXCONF_LOGPATH_TAGNAME;
     m_pcKeyArray[AXCONF_CLIENTLOGPATH]      = AXCONF_CLIENTLOGPATH_TAGNAME;
     m_pcKeyArray[AXCONF_CLIENTWSDDFILEPATH] = AXCONF_CLIENTWSDDFILEPATH_TAGNAME;
+    m_pcKeyArray[AXCONF_LOGFILTER]          = AXCONF_LOGFILTER_TAGNAME;
+
   
     m_pcKeyArray[AXCONF_AXISHOME]       = "\0"; // will be obtained dynamically.
     m_pcKeyArray[AXCONF_TRANSPORTHTTP]  = AXCONF_TRANSPORTHTTP_TAGNAME;
@@ -66,15 +69,18 @@
     m_pcValueArray[AXCONF_CHANNEL_HTTP]      = PLATFORM_CHANNEL_PATH;
     m_pcValueArray[AXCONF_SECUREINFO]        = PLATFORM_SECUREINFO;
     m_pcValueArray[AXCONF_AXISHOME]          = PLATFORM_DEFAULT_DEPLOY_PATH;
+    m_pcValueArray[AXCONF_LOGFILTER]         = "";
 }
 
 //AxisConfig::AxisConfig( bool bDefaultsOnly)
-AxisConfig::AxisConfig( AxisConfig * pOrgAxisConfig)
+AxisConfig::
+AxisConfig( AxisConfig * pOrgAxisConfig)
 {
     m_pcKeyArray[AXCONF_WSDDFILEPATH]       = AXCONF_WSDDFILEPATH_TAGNAME;
     m_pcKeyArray[AXCONF_LOGPATH]            = AXCONF_LOGPATH_TAGNAME;
     m_pcKeyArray[AXCONF_CLIENTLOGPATH]      = AXCONF_CLIENTLOGPATH_TAGNAME;
     m_pcKeyArray[AXCONF_CLIENTWSDDFILEPATH] = AXCONF_CLIENTWSDDFILEPATH_TAGNAME;
+    m_pcKeyArray[AXCONF_LOGFILTER]          = AXCONF_LOGFILTER_TAGNAME;
   
     m_pcKeyArray[AXCONF_AXISHOME]       = "\0"; // will be obtained dynamically.
     m_pcKeyArray[AXCONF_TRANSPORTHTTP]  = AXCONF_TRANSPORTHTTP_TAGNAME;
@@ -86,50 +92,42 @@
     m_pcKeyArray[AXCONF_LISTENPORT]     = AXCONF_LISTENPORT_TAGNAME;
     m_pcKeyArray[AXCONF_SECUREINFO]     = AXCONF_SECUREINFO_TAGNAME;
 
-	char *	pszDefaultValues[] = {"",							// (AXCONF_WSDDFILEPATH) Server WSDD File Path
-								  PLATFORM_LOG_PATH,			// (AXCONF_LOGPATH) Server log path
-								  PLATFORM_CLIENTLOG_PATH,		// (AXCONF_CLIENTLOGPATH) Client log path
-								  "",							// (AXCONF_CLIENTWSDDFILEPATH) Client WSDD File Path
-								  PLATFORM_DEFAULT_DEPLOY_PATH,	// (AXCONF_AXISHOME) Axis home
-								  PLATFORM_TRANSPORTHTTP_PATH,	// (AXCONF_TRANSPORTHTTP) Transport HTTP path
-								  "",							// (AXCONF_TRANSPORTSMTP) Transport SMTP path
-								  PLATFORM_XMLPARSER_PATH,		// (AXCONF_XMLPARSER) XML Parser path
-								  "server name",				// (AXCONF_NODENAME) Node name
-								  "listen port",				// (AXCONF_LISTENPORT) Listener port
-								  PLATFORM_SSLCHANNEL_PATH,		// (AXCONF_SSLCHANNEL_HTTP) HTTP SSL Channel
-								  PLATFORM_CHANNEL_PATH,		// (AXCONF_CHANNEL_HTTP) HTTP Channel
-								  PLATFORM_SECUREINFO};			// (AXCONF_SECUREINFO) HTTP SSL secure information
-
-	for( int iPropertyCount = 0; iPropertyCount < AXCONF_LAST; iPropertyCount++)
-	{
-		char *	pszValue = pOrgAxisConfig->getAxisConfProperty( (g_axconfig) iPropertyCount);
-
-		if( pszValue == NULL)
-		{
-			m_pcValueArray[iPropertyCount] = pszDefaultValues[iPropertyCount];
-		}
-		else
-		{
-			m_pcValueArray[iPropertyCount] = pszValue;
-		}
-	}
+    char *    pszDefaultValues[] = {
+    		"",                           // (AXCONF_WSDDFILEPATH) Server WSDD File Path
+            PLATFORM_LOG_PATH,            // (AXCONF_LOGPATH) Server log path
+            PLATFORM_CLIENTLOG_PATH,      // (AXCONF_CLIENTLOGPATH) Client log path
+            "",                           // (AXCONF_CLIENTWSDDFILEPATH) Client WSDD File Path
+            PLATFORM_DEFAULT_DEPLOY_PATH, // (AXCONF_AXISHOME) Axis home
+            PLATFORM_TRANSPORTHTTP_PATH,  // (AXCONF_TRANSPORTHTTP) Transport HTTP path
+            "",                           // (AXCONF_TRANSPORTSMTP) Transport SMTP path
+            PLATFORM_XMLPARSER_PATH,      // (AXCONF_XMLPARSER) XML Parser path
+            "server name",                // (AXCONF_NODENAME) Node name
+            "listen port",                // (AXCONF_LISTENPORT) Listener port
+            PLATFORM_SSLCHANNEL_PATH,     // (AXCONF_SSLCHANNEL_HTTP) HTTP SSL Channel
+            PLATFORM_CHANNEL_PATH,        // (AXCONF_CHANNEL_HTTP) HTTP Channel
+            PLATFORM_SECUREINFO,          // (AXCONF_SECUREINFO) HTTP SSL secure information
+            ""                            // (AXCONF_LOGFILTER) Log level
+    };
 
-	delete pOrgAxisConfig;
-/*
-	m_pcValueArray[AXCONF_NODENAME]			 = "server name";
-    m_pcValueArray[AXCONF_LISTENPORT]        = "listen port";
-    m_pcValueArray[AXCONF_XMLPARSER]         = PLATFORM_XMLPARSER_PATH;
-    m_pcValueArray[AXCONF_TRANSPORTHTTP]     = PLATFORM_TRANSPORTHTTP_PATH;
-    m_pcValueArray[AXCONF_LOGPATH]           = PLATFORM_LOG_PATH;
-    m_pcValueArray[AXCONF_CLIENTLOGPATH]     = PLATFORM_CLIENTLOG_PATH;
-    m_pcValueArray[AXCONF_SSLCHANNEL_HTTP]   = PLATFORM_SSLCHANNEL_PATH;
-    m_pcValueArray[AXCONF_CHANNEL_HTTP]      = PLATFORM_CHANNEL_PATH;
-    m_pcValueArray[AXCONF_SECUREINFO]        = PLATFORM_SECUREINFO;
-    m_pcValueArray[AXCONF_AXISHOME]          = PLATFORM_DEFAULT_DEPLOY_PATH;
-*/
+    for( int iPropertyCount = 0; iPropertyCount < AXCONF_LAST; iPropertyCount++)
+    {
+        char *    pszValue = pOrgAxisConfig->getAxisConfProperty( (g_axconfig) iPropertyCount);
+
+        if( pszValue == NULL)
+        {
+            m_pcValueArray[iPropertyCount] = pszDefaultValues[iPropertyCount];
+        }
+        else
+        {
+            m_pcValueArray[iPropertyCount] = pszValue;
+        }
+    }
+
+    delete pOrgAxisConfig;
 }
 
-int AxisConfig::readConfFile ()
+int AxisConfig::
+readConfFile ()
 {
     char carrLine[CONFBUFFSIZE];
     char *pcValue = NULL;
@@ -222,19 +220,69 @@
     return AXIS_SUCCESS;
 }
 
-void AxisConfig::setValue (int valuelength, g_axconfig valueindex, char *value)
+void AxisConfig::
+setValue (int valuelength, g_axconfig valueindex, char *value)
 {
     // m_pcValueArray is a string and the string class will copy the value, so 
     // no need to copy the value into our own storage here.
     m_pcValueArray[valueindex] = value;
 }
 
-char* AxisConfig::getAxisConfProperty (g_axconfig property)
+char* AxisConfig::
+getAxisConfProperty (g_axconfig property)
 {
     if (0 == m_pcValueArray[property].length()) return NULL;
     return (char*)(m_pcValueArray[property].c_str());
 }
 
+std::string AxisConfig::
+toString()
+{
+    // Write out the config settings
+    string confLine="-------------- Config File settings START ----------------\n";
+
+    const char *confProps[]={
+        "AXCONF_WSDDFILEPATH",        //0
+        "AXCONF_LOGPATH",             //1
+        "AXCONF_CLIENTLOGPATH",       //2
+        "AXCONF_CLIENTWSDDFILEPATH",  //3
+        "AXCONF_AXISHOME",         //4
+        "AXCONF_TRANSPORTHTTP",    //5
+        "AXCONF_TRANSPORTSMTP",    //6
+        "AXCONF_XMLPARSER",        //7
+        "AXCONF_NODENAME",         //8
+        "AXCONF_LISTENPORT",       //9
+        "AXCONF_SSLCHANNEL_HTTP",  //10
+        "AXCONF_CHANNEL_HTTP",     //11
+        "AXCONF_SECUREINFO",       //12 
+        "AXCONF_LOGFILTER"         //13 Please use this number in the #if below
+    };
+
+// Check at build time whether the lists of properties are in sync
+#if AXCONF_LAST > 14
+#error "The list of configuration properties in AxisConfig.h and AxisTrace.cpp are different. Please keep them in sync."
+#endif
+
+    for (unsigned j=0; j<sizeof(confProps)/sizeof(char*); j++) 
+    {
+        confLine += confProps[j];
+        confLine += " = ";
+
+        const char *value = getAxisConfProperty((g_axconfig)j);
+        if (NULL==value)
+            confLine += "NULL\n";
+        else 
+        {
+            confLine += value;
+            confLine += "\n";
+        }
+    }
+
+    
+    confLine += "-------------- Config File settings END OF ----------------\n";
+    
+    return confLine;
+}
 
 /*
 int main(void)

Modified: webservices/axis/trunk/c/src/common/AxisConfig.h
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/common/AxisConfig.h?rev=713841&r1=713840&r2=713841&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/common/AxisConfig.h (original)
+++ webservices/axis/trunk/c/src/common/AxisConfig.h Thu Nov 13 14:13:23 2008
@@ -39,6 +39,8 @@
 #define AXCONF_NODENAME_TAGNAME				"NodeName"
 #define AXCONF_LISTENPORT_TAGNAME			"ListenPort"
 #define AXCONF_SECUREINFO_TAGNAME			"SecureInfo"
+#define AXCONF_LOGFILTER_TAGNAME            "LogFilter"
+
 
 #include <axis/GDefine.hpp>
 #include <string>
@@ -71,6 +73,7 @@
 	AXCONF_SSLCHANNEL_HTTP,
 	AXCONF_CHANNEL_HTTP,
 	AXCONF_SECUREINFO,
+	AXCONF_LOGFILTER,
 	AXCONF_LAST
 };
 
@@ -80,7 +83,6 @@
 {
     public:
     AxisConfig();
-//    AxisConfig( bool bDefaultsOnly);
     AxisConfig( AxisConfig * pOrgAxisConfig);
 
     /**
@@ -101,6 +103,11 @@
 
 	char* getAxisConfProperty(g_axconfig property);
     void setValue(int valuelength, g_axconfig valueindex, char* value);
+    
+    /** 
+     * Return values in properties file as a string.
+     */
+    std::string toString();
         
     private:
 		std::string m_pcKeyArray [AXCONF_LAST];

Modified: webservices/axis/trunk/c/src/common/AxisTrace.cpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/common/AxisTrace.cpp?rev=713841&r1=713840&r2=713841&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/common/AxisTrace.cpp (original)
+++ webservices/axis/trunk/c/src/common/AxisTrace.cpp Thu Nov 13 14:13:23 2008
@@ -16,8 +16,6 @@
  *   limitations under the License.
  *
  *
- * @author Damitha Kumarage (damitha@opensource.lk, damitha@jkcsworld.com)
- *
  */
 
 // !!! This include file must be first thing in file !!!
@@ -31,583 +29,477 @@
 
 // cctype is needed to make isprint compile on linux
 #include <cctype>
-#include <exception>
 #include <ctime>
 #include <cstring>
 
-#include <axis/AxisException.hpp>
-
-#include "AxisUtils.h"
-#include "AxisConfig.h"
-
 #include "AxisTrace.h"
 
-
-extern AXIS_CPP_NAMESPACE_PREFIX AxisConfig* g_pConfig;
 AXIS_CPP_NAMESPACE_START
 using namespace std;
 
-enum AxisTraceState AxisTrace::m_bLoggingOn = STATE_UNINITIALISED;
-AxisFile *AxisTrace::m_fileTrace = NULL;
-
-AxisTraceEntrypoints g_traceEntrypoints = {
-    AxisTrace::traceLineInternal,
-    AxisTrace::traceEntryInternal,
-    AxisTrace::traceExitInternal,
-    AxisTrace::traceCatchInternal,
-    AxisTrace::isTraceOn
-};
+// Initialization of static trace variables.
+bool AxisTrace::m_logFileIsSet             = false;
 
+bool AxisTrace::m_stubLogLevelEnabled      = true;
+bool AxisTrace::m_engineLogLevelEnabled    = true;
+bool AxisTrace::m_parserLogLevelEnabled    = true;
+bool AxisTrace::m_transportLogLevelEnabled = true;
+bool AxisTrace::m_noEntryExit              = false;
+
+bool AxisTrace::m_consoleMode = false;
+
+string AxisTrace::m_logFilePath = "";
+
+//******************************************************************************
+//
+// AxisTrace::startTrace() Implementation
+//
+//******************************************************************************
 int AxisTrace::
-openFile ()
+startTrace(const char* logFilePath, 
+		   bool dumpEnvironment)
 {
-    return initialise(g_pConfig->getAxisConfProperty(AXCONF_LOGPATH), STATE_ON);
-}
-
-int AxisTrace::
-openFileByClient ()
-{
-    return initialise(g_pConfig->getAxisConfProperty(AXCONF_CLIENTLOGPATH), STATE_ON);
-}
-
-int AxisTrace::
-initialise(const char *filename, AxisTraceState newState) 
-{
-    AxisFile *newFile = NULL;
-    int result = AXIS_SUCCESS;
-    if (NULL != filename) 
-    {
-        newFile = new AxisFile();
-        if (NULL == newFile || 
-            AXIS_FAIL == newFile->fileOpen(filename, "a"))
-            result = AXIS_FAIL;
-    }
-
-    if (NULL != m_fileTrace) 
-    {
-        if (AXIS_FAIL == result) 
-        {
-            /*
-             * If we have failed to open the trace file specified in axiscpp.conf and the
-             * startup trace file is open then write a sensible error message out to the 
-             * startup trace file before we close it.
-             */
-            if (NULL == newFile)
-                traceLineInternal("Failed to open trace file in axiscpp.conf because of no storage");
-            else 
-            {
-                string text = "Failed to open trace file ";
-                text += filename;
-                text += " that was specified by ClientLogPath in axiscpp.conf";
-                traceLineInternal(text.c_str());
-            }
-        }
-        else 
-        {
-            traceLineInternal("Closing the startup trace file");
-        }
-        delete m_fileTrace;
-        m_fileTrace = NULL;
-    }
-    m_bLoggingOn = STATE_OFF;
-
-    if (NULL == filename || AXIS_FAIL == result)
-    {
-        if (NULL != newFile) delete newFile;
+    // If startTrace() already invoked, just return.
+    if (NULL == logFilePath || 0x00 == *logFilePath)
         return AXIS_FAIL;
-    }
 
-    m_fileTrace = newFile;
-    m_bLoggingOn = newState;
-    traceHeader(newState);
+    m_logFileIsSet = true;
+    
+    // Set log directory
+    m_logFilePath = logFilePath;
+    
+    // We need to do open here in order to ensure file is created and tagged as ASCII. 
+    // This is to cater to EBCDIC-based systems such as IBM i operating system.  Should really 
+    // not matter for ASCII-based operating systems such as UNIX and windows.
+    FILE *logFile = fopen(m_logFilePath.c_str(), TRACE_FILE_MODE1);
+    if (logFile != NULL)
+        fclose(logFile);
+
+    // Now dump out environment information
+    if (dumpEnvironment)
+    {
+	    string text = "************ Start Display Current Environment ************\n";
+	    text += "Axis C++ libraries built on ";
+	    text += __DATE__;
+	    text += " at ";
+	    text += __TIME__;
+	    text += "\n";
+	    writeTrace(text);
+	
+	    char *envVars[]={"AXISCPP_DEPLOY", "PATH","LIBPATH","LD_LIBRARY_PATH","SHLIB_PATH", 
+	        "PWD","CLASSPATH","INCLUDE","LIB","NLSPATH","OS",
+	        "COMPUTERNAME","USERNAME","HOSTNAME","LANG","LOGIN","LOGNAME",
+	        "MACHTYPE","OSTYPE","UID","USER"};
+	    for (unsigned i=0; i<(sizeof(envVars)/sizeof(char*)); i++) 
+	    {
+	        text = envVars[i];
+	        const char *value = getenv(envVars[i]);
+	        if (NULL!=value)
+	        {
+	            text += "=";
+	            text += value;
+	            text += "\n";
+	            writeTrace(text);
+	        }
+	    }
+	    writeTrace("************* End Display Current Environment *************\n");   
+    }
+    
     return AXIS_SUCCESS;
 }
 
+//******************************************************************************
+//
+// AxisTrace::stopTrace() Implementation
+//
+//******************************************************************************
 void AxisTrace::
-terminate() 
-{ 
-    m_bLoggingOn = STATE_STOPPED;
-    // Deleting m_fileTrace closes the trace file
-    if (NULL != m_fileTrace)
-        delete m_fileTrace; 
-    m_fileTrace = NULL; 
+stopTrace()
+{
+	m_logFilePath  = "";
+	m_logFileIsSet = false;
 }
 
-bool AxisTrace::
-isTraceOn()
-{ 
-    switch (m_bLoggingOn)
-    {
-    case STATE_OFF:
-    case STATE_STOPPED:
-        return false;
-
-    case STATE_ON:
-    case STATE_STARTUP:
-        return true;
+//******************************************************************************
+//
+// AxisTrace::setLogFilter() Implementation
+//
+//******************************************************************************
+void AxisTrace::
+setLogFilter(const char *filters)
+{
+	resetLogFilter();
+	
+    if (filters == NULL || *filters == 0x00)
+        return;
     
-    case STATE_UNINITIALISED:
-        return AXIS_SUCCESS==initialise(getenv("AXISCPP_STARTUP_TRACE"),STATE_STARTUP);
+    string filters_s = filters;
     
-    default:
-        return false;
-    }
+    if (filters_s.find(TRACE_FILTER_NOENTRYEXIT) != string::npos)
+        m_noEntryExit      = true;
+    
+    if (filters_s.find(TRACE_FILTER_STUB) == string::npos)
+        m_stubLogLevelEnabled      = false;
+    
+    if (filters_s.find(TRACE_FILTER_ENGINE) == string::npos)
+        m_engineLogLevelEnabled    = false;
+    
+    if (filters_s.find(TRACE_FILTER_PARSER) == string::npos)
+        m_parserLogLevelEnabled    = false;
+    
+    if (filters_s.find(TRACE_FILTER_TRANSPORT) == string::npos)
+        m_transportLogLevelEnabled = false;
 }
 
-int AxisTrace::
-logaxis (const char* sLog1, const char* sLog2, const char *type,
-         const char* file, int line)
+//******************************************************************************
+//
+// AxisTrace::getLogFilters() Implementation
+//
+//******************************************************************************
+string AxisTrace::
+getLogFilter()
 {
-    if (isTraceOn()) return AXIS_FAIL;
-
-    string name = file;
-    name += "@";
-    name += line;
-
-    string text = sLog1;
-    text += ":";
-    if(0 != sLog2)
-        text += sLog2;
-
-    traceLineInternal(type,name.c_str(),NULL,NULL,text.c_str());
-    return AXIS_SUCCESS;
+	string filters   = "";
+	string delimiter = ";";
+	
+	if (m_noEntryExit)
+		filters += TRACE_FILTER_NOENTRYEXIT + delimiter;
+	
+	if (m_stubLogLevelEnabled)
+		filters += TRACE_FILTER_STUB + delimiter;
+	
+	if (m_engineLogLevelEnabled)
+		filters += TRACE_FILTER_ENGINE + delimiter;
+	
+	if (m_parserLogLevelEnabled)
+		filters += TRACE_FILTER_PARSER + delimiter;
+	
+	if (m_transportLogLevelEnabled)
+		filters += TRACE_FILTER_TRANSPORT + delimiter;
+	
+	return filters;
 }
 
-int AxisTrace::
-trace (const char *pchLog)
+//******************************************************************************
+//
+// AxisTrace::resetLogFilters() Implementation
+//
+//******************************************************************************
+void AxisTrace::
+resetLogFilter()
 {
-    if (pchLog != NULL) {
-        traceLine(pchLog);
-    }
-    return AXIS_SUCCESS;
+	m_stubLogLevelEnabled      = true;
+	m_engineLogLevelEnabled    = true;
+	m_parserLogLevelEnabled    = true;
+	m_transportLogLevelEnabled = true;
+	m_noEntryExit              = false;
 }
 
+//******************************************************************************
+//
+// AxisTrace::enableConsoleMode() Implementation
+//
+//******************************************************************************
 void AxisTrace::
-traceHeader(enum AxisTraceState newState)
+enableConsoleMode()
 {
-    traceLine2("************ Start Display Current Environment ************");
-    string text = "Axis C++ libraries built on ";
-    text += __DATE__;
-    text += " at ";
-    text += __TIME__;
-    traceLine2(text.c_str());
-
-    time_t ltime;
-    time (&ltime);
-    if (STATE_ON==newState)
-        text = "Runtime trace produced on ";
-    else
-        text = "Startup trace produced on ";
-    text += ctime (&ltime);
-    traceLine2(text.c_str());
-
-    char *envVars[]={"PATH","LIBPATH","LD_LIBRARY_PATH","SHLIB_PATH", 
-        "AXISCPP_DEPLOY","PWD","CLASSPATH","INCLUDE","LIB","NLSPATH","OS",
-        "COMPUTERNAME","USERNAME","HOSTNAME","LANG","LOGIN","LOGNAME",
-        "MACHTYPE","OSTYPE","UID","USER"};
-    for (unsigned i=0; i<(sizeof(envVars)/sizeof(char*)); i++) 
-    {
-        text = envVars[i];
-        const char *value = getenv(envVars[i]);
-        if (NULL!=value)
-        {
-            text += "=";
-            text += value;
-            traceLine2(text.c_str());
-        }
-    }
-    traceLine2("************* End Display Current Environment *************");
-
-    if (STATE_STARTUP==newState) return;
-
-    // Write out the config settings
-    traceLine("-------------- Config File settings START ----------------");
-    string confLine="";
-
-    const char *confProps[]={
-        "AXCONF_WSDDFILEPATH",        //1
-        "AXCONF_LOGPATH",            //2
-        "AXCONF_CLIENTLOGPATH",        //3
-        "AXCONF_CLIENTWSDDFILEPATH",    //4
-        "AXCONF_AXISHOME",        //5
-        "AXCONF_TRANSPORTHTTP",        //6
-        "AXCONF_TRANSPORTSMTP",        //7
-        "AXCONF_XMLPARSER",        //8
-        "AXCONF_NODENAME",        //9
-        "AXCONF_LISTENPORT",        //10
-        "AXCONF_SSLCHANNEL_HTTP",    //11
-        "AXCONF_CHANNEL_HTTP",        //12
-        "AXCONF_SECUREINFO"};        //13 Please use this number in the #if below
-
-// Check at build time whether the lists of properties are in sync
-#if AXCONF_LAST > 13
-#error "The list of configuration properties in AxisConfig.h and AxisTrace.cpp are different. Please keep them in sync."
-#endif
-
-    for (unsigned j=0; j<sizeof(confProps)/sizeof(char*); j++) 
-    {
-        confLine ="";
-        confLine += confProps[j];
-        confLine += " = ";
-
-        const char *value = g_pConfig->getAxisConfProperty((g_axconfig)j);
-        if (NULL==value)
-            confLine += "NULL";
-        else 
-            confLine += value;
-
-        traceLine(confLine.c_str());
-    }
-
-    
-    traceLine("-------------- Config File settings END OF ----------------");
-
-
+    m_consoleMode = true;
 }
 
+//******************************************************************************
+//
+// AxisTrace::disableConsoleMode() Implementation
+//
+//******************************************************************************
 void AxisTrace::
-traceLineInternal(const char *type, const char *classname, 
-                  const char *methodname, const void *that, 
-                  const char *parms) 
+disableConsoleMode()
 {
-    if (!isTraceOn()) return;
+    m_consoleMode = false;
+}
 
+//******************************************************************************
+//
+// AxisTrace::writeEntry() Implementation
+//
+//******************************************************************************
+void AxisTrace::
+writeEntry   (const char* component, 
+		      const char* functionName, 
+              const char * fmt, 
+              ...)
+{
+	// If logging is not enabled, just return
+	if (!isLoggingEnabled())
+		return;
+	
+    // Filter out entry/exit? If so, simply return.
+    if (m_noEntryExit)
+        return;
     
-
-    PLATFORM_TIMEB timeBuffer;
-    PLATFORM_GET_TIME_IN_MILLIS( &timeBuffer );
-    struct tm *tm = localtime(&timeBuffer.time);
-
-    const int timelen=256;
-    char strtime[timelen];
-    memset(strtime,0,timelen);
-    strftime(strtime,timelen,"[%d/%m/%Y %H:%M:%S:",tm);
-    string text = strtime;
-    
-    char millis[5];
-    sprintf(millis, "%03u", timeBuffer.millitm);
-    text += millis;
-    
-    strftime(strtime, timelen, " %Z]", tm);
-    text += strtime;
-
-    char threadID[20];
-    sprintf(threadID, " %lu ", PLATFORM_GET_THREAD_ID);
-    text += threadID;
-
-    if (NULL==classname) text += "-";
-    else text += classname;
-    text += " ";
-    text += type;
-    if (NULL!=methodname) 
-    {
-        text += " ";
-        text += methodname;
-    }
-    text += " ";
-    if (NULL != that) 
-    {
-        char prim[32];
-        sprintf(prim,"@%p",that);
-        text += prim;
-        if (NULL!=parms) 
-        	text += ",";
-    }
-
-    if (NULL != parms) 
-    {
-        if (NULL==strchr(parms,'\n')) 
-        {
-            text += parms;
-            traceLine2(text.c_str());
-        } 
-        else 
-        {
-            // Multi-line output
-            text += "------------>";
-            traceLine2(text.c_str());
-            const char *tok = strtok(const_cast<char*>(parms),"\n");
-            while (NULL != tok) 
-            {
-                traceLineInternal(tok);
-                tok = strtok(NULL,"\n");
-            }
-        }
-    } 
-    else 
-    {
-        traceLine2(text.c_str());
-    }
+    // Construct final formatter
+    char myfmt[1024];
+    if (NULL == fmt)
+        fmt = "";
+    sprintf(myfmt, "%s %s %s(): %s\n", component, TRACE_TYPE_ENTRY, functionName, fmt);
+    
+    va_list vargs;
+    va_start(vargs,fmt);
+    writeTrace(myfmt, vargs);        
+    va_end(vargs);
 }
 
+//******************************************************************************
+//
+// AxisTrace::writeExit() Implementation
+//
+//******************************************************************************
 void AxisTrace::
-traceLineInternal(const char *data) 
-{
-    traceLineInternal(TRACE_INFO,NULL,NULL,NULL,data);
+writeExit   (const char* component,
+		     const char* functionName, 
+             const char * fmt, 
+             ...)
+{
+	// If logging is not enabled, just return
+	if (!isLoggingEnabled())
+		return;
+	
+    // Filter out entry/exit? If so, simply return.
+    if (m_noEntryExit)
+        return;
+    
+    // Construct final formatter
+    char myfmt[1024];
+    if (NULL == fmt)
+        fmt = "";
+    sprintf(myfmt, "%s %s %s(): %s\n", component, TRACE_TYPE_EXIT, functionName, fmt);
+    
+    va_list vargs;
+    va_start(vargs,fmt);
+    writeTrace(myfmt, vargs);        
+    va_end(vargs);
 }
 
+//******************************************************************************
+//
+// AxisTrace::writeTrace() Implementation
+//
+//******************************************************************************
 void AxisTrace::
-traceLine2(const char *data) 
-{
-    m_fileTrace->filePuts(data);
-    m_fileTrace->filePuts("\n");
-    m_fileTrace->fileFlush();
-    return;
+writeTrace  (const char* component,
+		     const char* type,
+             const char* functionName, 
+             const char * fmt, 
+             ...)
+{
+	// If logging is not enabled, just return
+	if (!isLoggingEnabled())
+		return;
+	
+    // Construct final formatter
+    char myfmt[1024];
+    if (NULL == fmt)
+        fmt = "";
+    sprintf(myfmt, "%s %s %s(): %s\n", component, type, functionName, fmt);
+    
+    va_list vargs;
+    va_start(vargs,fmt);
+    writeTrace(myfmt, vargs);        
+    va_end(vargs);
 }
 
+//******************************************************************************
+//
+// AxisTrace::writeTrace() Implementation
+//
+//******************************************************************************
 void AxisTrace::
-traceEntryInternal(const char *className, const char *methodName, 
-    const void *that, int nParms, va_list args)
-{
-    if (!isTraceOn()) return;
-
-    try 
-    {
-        string line;
-        const char *parms = NULL;
-        if (0<nParms) 
-        {
-            for (int i=0; i<nParms; i++) 
-            {
-                int type = va_arg(args, int);
-                unsigned len = va_arg(args, unsigned);
-                void *value = va_arg(args, void*);
-                if (0!=i) line += ", ";
-                addParameter(line,type,len,value);
-            }
-            parms = line.c_str();
-        }
-
-        traceLineInternal(TRACE_ENTRY,className,methodName,that,parms);
-    } 
-    catch (...) 
-    {
-        traceLineInternal(TRACE_EXCEPT,NULL,NULL,NULL,"Unknown exception caught during trace entry");
-    }
+writeTrace   (const char* component,
+		      const char* type,
+              const char* functionName, 
+              int lineNumber, 
+              const char* fileName, 
+              const char * fmt, 
+              ...)
+{
+	// If logging is not enabled, just return
+	if (!isLoggingEnabled())
+		return;
+	
+    // Construct final formatter
+    char myfmt[1024];
+    if (NULL == fmt)
+        fmt = "";
+    sprintf(myfmt, "%s %s %s(): Line=%d: File=%s:\n%s\n", component, type, functionName, lineNumber, fileName, fmt);
+    
+    va_list vargs;
+    va_start(vargs,fmt);
+    writeTrace(myfmt, vargs);        
+    va_end(vargs);
 }
 
+//******************************************************************************
+//
+// AxisTrace::writeTrace() Implementation
+//
+//******************************************************************************
 void AxisTrace::
-traceExitInternal(const char *className, const char *methodName, const void* that, int returnIndex,
-                  int type, unsigned len, void *value)
-{
-    if (!isTraceOn()) return;
-
-    try 
+writeTrace(const char* component, 
+		   const char* type, 
+		   const char* functionName,
+           bool hexFormat, 
+           int dataLen, 
+           const char *data)
+{
+	// If logging is not enabled, just return
+	if (!isLoggingEnabled())
+		return;
+	
+    int len = 0;
+    
+    if (NULL == data || dataLen==0)
+        return;
+    
+    // Construct final formatter - the confuscated nature of the code is due to 
+    // the support of EBCDIC based systems.
+    char myfmt[1024];
+    sprintf(myfmt, "%s %s %s(): \n", component, type, functionName);
+    string prefix;
+    generatePrefix(prefix, myfmt);
+    PLATFORM_STRTOASC(prefix.c_str());
+    
+    if (!m_logFilePath.empty())
     {
-        string line;
-        bool added = false;
-        if (0!=returnIndex) 
-        { 
-        	// Zero means only one return
-               line = "@";
-               char prim[32];
-               sprintf(prim,"%d",returnIndex);
-               line += prim;
-               added = true;
-        }
-
-        if (TRACETYPE_UNKNOWN != type) 
+        FILE *logFile = fopen(m_logFilePath.c_str(), TRACE_FILE_MODE1);
+        if (logFile != NULL)
         {
-            if (added) line += " ";
-            addParameter(line,type,len,value);
-            added = true;
+            fprintf(logFile, "%s%*s%s", prefix.c_str(), dataLen, data, "\x0a");
+            fflush(logFile);
+            fclose(logFile);
         }
-
-        traceLineInternal(TRACE_EXIT,className,methodName,that,added?line.c_str():NULL);
-    } 
-    catch (...) 
+    }
+    
+    if (m_consoleMode)
     {
-        traceLineInternal(TRACE_EXCEPT,NULL,NULL,NULL,"Unknown exception caught during trace exit");
+    	fprintf(stdout, myfmt, dataLen, data);
+        fflush(stdout);
     }
 }
 
+//******************************************************************************
+//
+// AxisTrace::writeTrace() Implementation
+//
+//******************************************************************************
 void AxisTrace::
-traceCatchInternal(const char *className, const char *methodName, const void* that, int catchIndex,
-                   int type, unsigned len, void *value)
+writeTrace(const char* data, int dataLen, bool hexFormat)
 {
-    if (!isTraceOn()) return;
-
-    try 
+	// If logging is not enabled, just return
+	if (!isLoggingEnabled())
+		return;
+	
+    int len = 0;
+    
+    if (NULL == data || dataLen==0)
+        return;
+    
+    if (!m_logFilePath.empty())
     {
-        string line;
-        if (0!=catchIndex) 
-        { 
-        	// Zero means only one catch
-              line = "@";
-              char prim[32];
-              sprintf(prim,"%d",catchIndex);
-              line += prim;
-              line += " ";
+        FILE *logFile = fopen(m_logFilePath.c_str(), TRACE_FILE_MODE2);
+        if (logFile != NULL)
+        {
+            len = fwrite(data, 1, dataLen, logFile);
+            fflush(logFile);
+            fclose(logFile);
         }
-
-        line += "caught ";
-        if (TRACETYPE_UNKNOWN != type)
-            addParameter(line,type,len,value);
-        else line += "\"...\"";
-        traceLineInternal(TRACE_EXCEPT,className,methodName,that,line.c_str());
-    } 
-    catch (...) 
+    }
+    
+    if (m_consoleMode)
     {
-        traceLineInternal(TRACE_EXCEPT,NULL,NULL,NULL,"Unknown exception caught during trace catch");
+        len = fwrite(data, 1, dataLen, stdout);
+        fflush(stdout);
     }
 }
 
+//******************************************************************************
+//
+// AxisTrace::writeTrace() Implementation
+//
+//******************************************************************************
 void AxisTrace::
-addParameter(string& line, int type, unsigned len, void *value)
+writeTrace(string& s)
 {
-    char prim[32]; // Plenty big enough to hold a primitive
-    char *pcValue = (char*)value;
-    
-    switch (type) 
-    {
-	    case TRACETYPE_CHAR:    sprintf(prim,"%c" ,*((char  *)value));    line += prim;    break;
-	    case TRACETYPE_USHORT:  sprintf(prim,"%hu",*((short *)value));    line += prim;    break;
-	    case TRACETYPE_SHORT:   sprintf(prim,"%hd",*((short *)value));    line += prim;    break;
-	    case TRACETYPE_UINT:    sprintf(prim,"%u" ,*((int   *)value));    line += prim;    break;
-	    case TRACETYPE_INT:     sprintf(prim,"%d" ,*((int   *)value));    line += prim;    break;
-	    case TRACETYPE_ULONG:   sprintf(prim,"%lu",*((long  *)value));    line += prim;    break;
-	    case TRACETYPE_LONG:    sprintf(prim,"%ld",*((long  *)value));    line += prim;    break;
-	    case TRACETYPE_DOUBLE:  sprintf(prim,"%f" ,*((double*)value));    line += prim;    break;
-	    case TRACETYPE_FLOAT:   sprintf(prim,"%f" ,*((float *)value));    line += prim;    break;
-	
-	    case TRACETYPE_BOOL:
-	        line += *((bool*)value)?"true":"false";
-	        break;
-	
-	    case TRACETYPE_POINTER:    
-	        pcValue = *((char**)pcValue);
-	        sprintf(prim,"%p ",pcValue);    
-	        line += prim;    
-	        if (NULL!=pcValue) 
-	            addDataParameter(line,len,value);
-	        break;
-	    
-	    case TRACETYPE_DATA:    
-	        addDataParameter(line,len,value);
-	        break;
-	
-	    case TRACETYPE_STRING:    
-	        try 
-	        {
-                pcValue = *((char**)pcValue);
-                if (NULL==pcValue) 
-                	line += "<null>";
-                else 
-                {
-                	line += "\"";    
-                	line += pcValue;    
-                	line += "\"";
-                }    
-	        } 
-	        catch (...) 
-	        {
-	            line += "<BADPOINTER>";
-	        }
-	        break;
-	
-	    case TRACETYPE_STLSTRING:
-	        try {
-	            string *str = static_cast<string*>(value);
-	            if (str) 
-	            {
-	                line += "\"";    
-	                line += str->c_str();
-	                line += "\"";    
-	            } 
-	            else 
-	            	line += "<BADPOINTER>";
-	        } 
-	        catch (...) 
-	        {
-	            line += "<BADPOINTER>";
-	        }
-	        break;
-	
-	    case TRACETYPE_EXCEPTION:
-	        try 
-	        {
-	            exception *ex = static_cast<exception*>(value);
-	            const char *msg = ex->what();
-	            if (NULL==msg) 
-	            	msg = "\?\?\?\?";
-	            line += "exception(\"";
-	            line += msg;
-	            line += "\")";    
-	        } 
-	        catch (...) 
-	        {
-	            line += "<BADPOINTER>";
-	        }
-	        break;
-	
-	    case TRACETYPE_AXISEXCEPTION:
-	        try 
-	        {
-	            AxisException *ex = static_cast<AxisException*>(value);
-	            const int code = ex->getExceptionCode();
-	            const char *msg = ex->what();
-	            if (NULL==msg) 
-	            	msg = "\?\?\?\?";
-	            line += "AxisException(";    
-	            line += code;
-	            line += ", \"";
-	            line += msg;
-	            line += "\")";    
-	        } 
-	        catch (...) 
-	        {
-	            line += "<BADPOINTER>";
-	        }
-	        break;
+	// If logging is not enabled, just return
+	if (!isLoggingEnabled())
+		return;
 	
-	    case TRACETYPE_ANONYMOUS:
-	        line += "<ANONYMOUS>";                
-	        break;
-	
-	    default:
-	        sprintf(prim,"%d",type);
-	        line += "<UNKNOWNTYPE";                
-	        line += prim;
-	        line += ">";
-	        break;
-    }
+    writeTrace(s.c_str(), s.length());
 }
 
-/**
- * This code only prints out the first 32 bytes of storage pointed at by a 
- * pointer. This is to prevent huge blocks of atorage repeatedly being output
- * to the trace file. 32 bytes seems quite a low limit. Maybe this limit 
- * could be increased in the future. Large blocks of storage could be output
- * in a more human-friendly format.
- */
+//******************************************************************************
+//
+// AxisTrace::writeTrace() Implementation
+//
+//******************************************************************************
 void AxisTrace::
-addDataParameter(string& line, unsigned len, void *value) 
+writeTrace(const char* fmt,
+           va_list vargs)
 {
-    char prim[32]; // Plenty big enough to hold a primitive
-    char *pcValue = (char*)value;
-    try 
+    int len = 0;
+    string prefix;
+    generatePrefix(prefix, fmt);
+    
+    // Dump the data 
+    
+    if (!m_logFilePath.empty())
     {
-        line += "[";
-        for (unsigned i=0; i<len && i<32; i++) 
-        {
-            int x = (int)(pcValue[i]);
-            sprintf(prim,"%2.2X",x);
-            line += prim;
-        }
-        line += "] <";
-        for (unsigned j=0; j<len && j<32; j++) 
+        FILE *logFile = fopen(m_logFilePath.c_str(), TRACE_FILE_MODE2);
+        if (logFile != NULL)
         {
-            char c = pcValue[j];
-            if (!isprint(c)) c='.';
-            sprintf(prim,"%c",c);
-            line += prim;
+            len = vfprintf(logFile, prefix.c_str(), vargs);
+            fflush(logFile);
+            fclose(logFile);
         }
-        line += ">";
-    } 
-    catch (...) 
+    }
+    
+    if (m_consoleMode)
     {
-        line += "<BADPOINTER>";
+        len = vfprintf(stdout, prefix.c_str(), vargs);
+        fflush(stdout);
     }
 }
 
+//******************************************************************************
+//
+// AxisTrace::generatePrefix() Implementation
+//
+//******************************************************************************
+void AxisTrace::
+generatePrefix(string &prefix, const char *fmt)
+{
+    if (NULL == fmt)
+        fmt = "";
+		
+    const int workBufLen=1024;
+    char workBuf[workBufLen];
+    memset(workBuf,0,workBufLen);
+    
+    // Generate trace timestamp.
+    PLATFORM_TIMEB timeBuffer;
+    PLATFORM_GET_TIME_IN_MILLIS( &timeBuffer );
+    struct tm *tm = localtime(&timeBuffer.time);
+    strftime(workBuf,workBufLen,"[%d/%m/%Y %H:%M:%S:", tm);
+    prefix = workBuf;
+    sprintf(workBuf, "%03u] ", timeBuffer.millitm);
+    prefix += workBuf;
+    
+    // Generate trace thread ID - on some system thread ID is long long (64 bits)!
+    LONGLONG tid = (LONGLONG)PLATFORM_GET_THREAD_ID;
+    sprintf(workBuf, PRINTF_LONGLONG_LOG_FORMAT_SPECIFIER, tid);
+    prefix += workBuf;
+    prefix += "  ";
+    
+    // Add the format passed-in.
+    prefix += fmt;
+}
+
 AXIS_CPP_NAMESPACE_END

Modified: webservices/axis/trunk/c/src/common/AxisTrace.h
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/common/AxisTrace.h?rev=713841&r1=713840&r2=713841&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/common/AxisTrace.h (original)
+++ webservices/axis/trunk/c/src/common/AxisTrace.h Thu Nov 13 14:13:23 2008
@@ -15,366 +15,333 @@
  *   limitations under the License.
  */ 
 
-/**
- * @file AxisTrace.h
- *
- * @author Damitha Kumarage (damitha@opensource.lk, damitha@jkcsworld.com)
- *
- */
   
 #ifndef __AXISLOG_H_INCLUDED_
 #define __AXISLOG_H_INCLUDED_
 
-#include "AxisFile.h"
 #include <string>
-#include <stack>
 #include <stdio.h>
 #include <stdarg.h>
 
-// Trace only gets traced if the runtime flag is on
-  #define AXISTRACE1(X, L) AxisTrace::logaxis(X,NULL,"W",__FILE__,__LINE__);
-  #define AXISTRACE2(X, Y, L) AxisTrace::logaxis(X,Y,"W",__FILE__,__LINE__);
-  #define AXISTRACE3(X) AxisTrace::trace(X);
+#include <axis/GDefine.hpp>
 
-/**
- * @class AxisTrace
- * @brief This is class is used to log messages when AXISTRACE is defined.
- *
- * writing to the log could be disabled by commenting the line 
- * #define ENABLE_AXISTRACE
- * of Axisconfig.h.   
- * @author Damitha Kumarage (damitha@opensource.lk, damitha@jkcsworld.com)
- */
+using namespace std;
+
+// Types of trace records
+#define TRACE_TYPE_ENTRY  ">"
+#define TRACE_TYPE_EXIT   "<"
+#define TRACE_TYPE_AUDIT  "A"
+#define TRACE_TYPE_DEBUG  "D"
+#define TRACE_TYPE_EVENT  "E"
+#define TRACE_TYPE_INFO   "I"
+#define TRACE_TYPE_UNCOND "U"
+#define TRACE_TYPE_WARN   "W"
+#define TRACE_TYPE_EXCEPT "X"
+
+// Trace components
+#define TRACE_COMPONENT_ENGINE    "engine    "
+#define TRACE_COMPONENT_STUB      "stub      "
+#define TRACE_COMPONENT_TRANSPORT "transport "
+#define TRACE_COMPONENT_PARSER    "parser    "
+
+// Trace filters
+#define TRACE_FILTER_NOENTRYEXIT  "noEntryExit"
+#define TRACE_FILTER_ENGINE       "engine"
+#define TRACE_FILTER_STUB         "stub"
+#define TRACE_FILTER_TRANSPORT    "transport"
+#define TRACE_FILTER_PARSER       "parser"
 
 AXIS_CPP_NAMESPACE_START
 
-// Unfortunately the trace type has to be an int with #defines, not an enum because
-// it is used with '...' and va_args, and ints can be used with '...' but enums 
-// cannot.
-#define TRACETYPE_UNKNOWN        0
-#define TRACETYPE_CHAR           1
-#define TRACETYPE_USHORT         2
-#define TRACETYPE_SHORT          3
-#define TRACETYPE_UINT           4
-#define TRACETYPE_INT            5
-#define TRACETYPE_ULONG          6    
-#define TRACETYPE_LONG           7
-#define TRACETYPE_DOUBLE         9
-#define TRACETYPE_FLOAT          10
-#define TRACETYPE_BOOL           11
-#define TRACETYPE_POINTER        12
-#define TRACETYPE_DATA           13
-#define TRACETYPE_STRING         14
-#define TRACETYPE_STLSTRING      15
-#define TRACETYPE_ANONYMOUS      16
-#define TRACETYPE_EXCEPTION      17
-#define TRACETYPE_AXISEXCEPTION  18
-
-#define TRACE_ENTRY  ">"
-#define TRACE_EXIT   "<"
-#define TRACE_AUDIT  "A"
-#define TRACE_DEBUG  "D"
-#define TRACE_EVENT  "E"
-#define TRACE_INFO   "I"
-#define TRACE_SYSOUT "O"
-#define TRACE_UNCOND "U"
-#define TRACE_WARN   "W"
-#define TRACE_EXCEPT "X"
-
-/*
- * enum AxisTraceState gives the states that trace can be in. This is primarily
- * to support startup trace. So initially trace is uninitialised. Then at the 
- * first trace call isTraceOn decides whether startup trace should be on and
- * either initialises startup trace or switches trace off. Then when axiscpp.conf
- * is read in openFile() or openFileByClient() is called which switches trace off
- * or on depending on how ClientLogPath or LogPath is set. Either way startup 
- * trace is switched off when axiscpp.conf is read in. When trace is terminated,
- * trace is set to stopped.
+/**
+ * Class used to enable tracing.  Used by all components.  To enable trace that
+ * is sent to a file,one needs to invoke startTrace() method. To enable trace that is 
+ * sent to stdout, invoke  enableConsoleMode().  Note that console mode and trace to 
+ * a file can be active at the same time. To terminate trace, invoke stop().
+ * <P>
+ * Axis components are made of the engine, the parser, the transport, and the stubs (client
+ * and server) that are generated by the WSDL2Ws tool.   The tracing facility by default will 
+ * trace all the components when tracing is enabled (currently the stubs are not generated). 
+ * One can filter out what is traced by setting the LogFilter configutation variable.  
+ * For example, if one wanted to produce trace data that does not include entry/exit records 
+ * and only includes the transport and parser components, one would invoke setLogFilter() as 
+ * follows:
+ * <xmp>
+ *        setLogFilter("transport;parser;noEntryExit")
+ * </xmp>
+ * <P>
+ * The above statement will produce trace records for the parser and transport component, and will 
+ * exclude entry/exit trace records - showing only debug and exception (if any occur) records.
+ * <P>
+ * It should be noted that setting log filter to NULL string or NULL pointer is equivalent to:
+ * <xmp>
+ *    setLogFilter("stub;engine;transport;parser")
+ * </xmp>
+ * 
+ * @author Nadir Amra (amra@us.ibm.com)
  */
-enum AxisTraceState
+class AxisTrace
 {
-    STATE_UNINITIALISED=0,
-    STATE_OFF,
-    STATE_ON,
-    STATE_STOPPED,
-    STATE_STARTUP
-};
+public:		
+	// Starting and stopping trace.  If log file path is not set, no logging is done
+	// unless ConsoleMode is enabled, in which case log records will be written to stdout.
+	static int startTrace(const char* logFilePath, bool dumpEnvironment=true);
+	static void stopTrace();
+	static bool isLoggingEnabled() { return (m_logFileIsSet || m_consoleMode); }  
+	
+	static std::string& getLogFilePath() { return m_logFilePath; }
+	
+	// Setting log filters.  The string filter is a semicolon delimited string
+	// of possible filters.  For example, setLogFilter("noEntryExit;").
+	static void setLogFilter(const char *filters);
+	static std::string getLogFilter();
+	
+	// Rest log filters to default values, which is: "stub;engine;transport;parser"
+	static void resetLogFilter();
+	
+	// Whether to print log records to the console (i.e. stdout).
+	static void enableConsoleMode();
+	static void disableConsoleMode();
+	
+	// Entry/exit tracing.
+	static void writeEntry  (const char* component, const char* functionName, const char * fmt, ...);
+	static void writeExit   (const char* component, const char* functionName, const char * fmt, ...);
+
+	// Write trace data. Trace records will include prefix (i.e. timestamp, etc).
+	static void writeTrace  (const char* component, const char* type, const char* functionName,
+			                 const char * fmt, ...);
+	static void writeTrace  (const char* component, const char* type, const char* functionName,
+			                 int lineNumber, const char* fileName, const char * fmt, ...);
+	static void writeTrace  (const char* component, const char* type, const char* functionName,
+			                 bool hexFormat, int dataLen, const char *data);
+	static void writeTrace  (const char *fmt, va_list vargs);
+
+	// Write trace data.  No trace record prefix is printed out (i.e. no timestamp, etc).
+	static void writeTrace  (std::string& s);
+	static void writeTrace  (const char *data, int dataLen, bool hexFormat=false);
+	static void writeTrace  (const char *str) { writeTrace(str, strlen(str)); }
+
+    // To determine when a log component is enabled.
+    static bool isStubLoggingEnabled()      { return  m_stubLogLevelEnabled;      }
+    static bool isEngineLoggingEnabled()    { return  m_engineLogLevelEnabled;    }
+    static bool isParserLoggingEnabled()    { return  m_parserLogLevelEnabled;    }
+    static bool isTransportLoggingEnabled() { return  m_transportLogLevelEnabled; }
 
-class STORAGE_CLASS_INFO AxisTraceEntrypoints {
-public:
-    void (*m_traceLine)(const char *data);
-    void (*m_traceEntry)(const char *className, const char *methodName, const void* that, int nParms, va_list vargs);
-    void (*m_traceExit)(const char *className, const char *methodName, const void* that, int returnIndex,
-        int type, unsigned len, void *value);
-    void (*m_traceCatch)(const char *className, const char *methodName, const void* that, int catchIndex,
-        int type, unsigned len, void *value);
-    bool (*m_traceOn) ();
+private:
+	// Internal function for writing trace data
+	static void generatePrefix(std::string &prefix, const char *fmt);
+
+	// Data fields.
+	static bool          m_logFileIsSet;
+	
+	static bool          m_stubLogLevelEnabled;
+	static bool          m_engineLogLevelEnabled;
+	static bool          m_parserLogLevelEnabled;
+	static bool          m_transportLogLevelEnabled;
+
+	static bool          m_consoleMode;
+	
+	static bool          m_noEntryExit;
+
+    static std::string   m_logFilePath;        
 };
 
-#ifdef AXISTRACE_LIBRARY
-    extern AxisTraceEntrypoints *g_traceEntrypoints;
-#elif !defined(AXIS_CLIENTC_LIB)
-    extern AxisTraceEntrypoints g_traceEntrypoints;
-#endif
 
-#ifdef AXISTRACE_LIBRARY_MAINENTRYPOINT
-    AxisTraceEntrypoints *g_traceEntrypoints = NULL;
-#endif
+AXIS_CPP_NAMESPACE_END
 
-class STORAGE_CLASS_INFO AxisTrace
-{
-public:
-    AxisTrace() {};
-    virtual ~AxisTrace() {};
-
-    /**
-     * This is called in writing to the log file whose path is specified in 
-     * $AXISCPP_DEPLOY/axiscpp.conf file. This method is used when the caller 
-     * has two string messages as arguments. One may be his own message.
-     * The other may be to print a trace value. User can also specify the 
-     * severity of the message by assigning level argument to one of CRITICAL, 
-     * WARN, INFO or TRIVIAL.
-     * 
-     * @param sLog1 string message one
-     * @param sLog2 string message two  
-     * @param level severity level
-     * @param arg3 file name
-     * @param arg4 line number
-     * 
-     * @return Operation status: AXIS_SUCCESS or AXIS_FAIL.
-     */
-    static int logaxis(const char* sLog1, const char* sLog2, const char *type, const char* file, int line);
-
-    /**
-     * Writes the given string to the standard console. 
-     * 
-     * @param pchLog The given string which will be printed to the  standard console.
-     * 
-     * @return Operation status: AXIS_SUCCESS or AXIS_FAIL.
-     */
-    static int trace(const char* pchLog);
-
-    /**
-     * Log file is opened for logging server side log messages.
-     * The file is created( if one is already not there) with the name and 
-     * path specified in AXISCPP_DEPLOY/axiscpp.conf file when web server loads.
-     *
-     * @return Operation status: AXIS_SUCCESS or AXIS_FAIL.
-     */
-    static int openFile();
-
-    /**
-     * Log file is opened for logging client side log messages
-     * The file is created with the name ClientAxisLog if one is not 
-     * already in the current path.
-     * 
-     * @return Operation status: AXIS_SUCCESS or AXIS_FAIL.
-     */
-    static int openFileByClient();
-
-    /**
-     * Finds out whether trace is on.
-     */
-#ifdef AXISTRACE_LIBRARY
-    static inline bool isTraceOn() { return (*g_traceEntrypoints->m_traceOn)(); }
-#else
-    static bool isTraceOn();
-#endif
+// ==================================================================================
+// Macros to do tracing setup, used when entry/exit is not wanted
+// ==================================================================================
+
+#define logSetFunctionNameStub(lFunctionName) \
+const char*       logFunctionName   = lFunctionName; \
+const char*       logComponent      = TRACE_COMPONENT_STUB; \
+bool              loggingEnabled    = (AxisTrace::isLoggingEnabled() && AxisTrace::isStubLoggingEnabled());
+
+#define logSetFunctionNameEngine(lFunctionName) \
+const char*       logFunctionName   = lFunctionName; \
+const char*       logComponent      = TRACE_COMPONENT_ENGINE; \
+bool              loggingEnabled    = (AxisTrace::isLoggingEnabled() && AxisTrace::isEngineLoggingEnabled());
+
+#define logSetFunctionNameParser(lFunctionName) \
+const char*       logFunctionName   = lFunctionName; \
+const char*       logComponent      = TRACE_COMPONENT_PARSER; \
+bool              loggingEnabled    = (AxisTrace::isLoggingEnabled() && AxisTrace::isParserLoggingEnabled());
+
+#define logSetFunctionNameTransport(lFunctionName) \
+const char*       logFunctionName   = lFunctionName; \
+const char*       logComponent      = TRACE_COMPONENT_TRANSPORT; \
+bool              loggingEnabled    = (AxisTrace::isLoggingEnabled() && AxisTrace::isTransportLoggingEnabled());
+
+// ==================================================================================
+// Macros to simply use of entry tracing
+// ==================================================================================
 
-    /**
-     * Traces a single line.
-     */  
-#ifdef AXISTRACE_LIBRARY
-    static inline void traceLine(const char *data) {(*g_traceEntrypoints->m_traceLine)(data); }
-#else
-    static inline void traceLine(const char *data) {traceLineInternal(data);}
-    static void traceLineInternal(const char *type, const char *classname, 
-                                  const char *methodname, const void *that, 
-                                  const char *parms);
-#endif
-    static void traceLineInternal(const char *data);
+#define logEntryStub(lFunctionName) \
+logSetFunctionNameStub(lFunctionName) \
+{ \
+  if (loggingEnabled) { \
+	  AxisTrace::writeEntry(logComponent, logFunctionName, NULL); \
+  } \
+}
 
-    /**
-     * Traces the entry to a method.
-     */
-#ifdef AXISTRACE_LIBRARY
-    static inline void traceEntry(const char *className, const char *methodName, const void* that, int nParms, ...) 
-    { 
-            va_list vargs;
-            va_start(vargs,nParms);
-            (*g_traceEntrypoints->m_traceEntry)(className,methodName,that,nParms,vargs);
-            va_end(vargs);
-    }
-#else
-    static inline void traceEntry(const char *className, const char *methodName, const void* that, int nParms, ...) 
-    {
-            va_list vargs;
-            va_start(vargs,nParms);
-            traceEntryInternal(className,methodName,that,nParms,vargs);
-            va_end(vargs);
-    }
-#endif
-    static void traceEntryInternal(const char *className, const char *methodName, 
-            const void* that, int nParms, va_list vargs);
+#define logEntryEngine(lFunctionName) \
+logSetFunctionNameEngine(lFunctionName) \
+{ \
+  if (loggingEnabled) { \
+	  AxisTrace::writeEntry(logComponent, logFunctionName, NULL); \
+  } \
+}
 
-    /**
-     * Traces the exit to a method.
-     */
-#ifdef AXISTRACE_LIBRARY
-    static inline void traceExit(const char *className, const char *methodName, const void* that, int returnIndex,
-        int type=TRACETYPE_UNKNOWN, unsigned len=0, void *value=0) { 
-            (*g_traceEntrypoints->m_traceExit)(className,methodName,that,returnIndex,type,len,value); 
-    }
-#else
-    static inline void traceExit(const char *className, const char *methodName, const void* that, int returnIndex,
-        int type=TRACETYPE_UNKNOWN, unsigned len=0, void *value=0) {
-        traceExitInternal(className,methodName,that,returnIndex,type,len,value);
-    }
-#endif
-    static void traceExitInternal(const char *className, const char *methodName, const void* that, int returnIndex,
-        int type=TRACETYPE_UNKNOWN, unsigned len=0, void *value=0);
+#define logEntryParser(lFunctionName) \
+logSetFunctionNameParser(lFunctionName) \
+{ \
+  if (loggingEnabled) { \
+	  AxisTrace::writeEntry(logComponent, logFunctionName, NULL); \
+  } \
+}
 
-    /**
-     * Traces something that has been caught
-     */
-#ifdef AXISTRACE_LIBRARY
-    static inline void traceCatch(const char *className, const char *methodName, const void* that, int catchIndex,
-        int type=TRACETYPE_UNKNOWN, unsigned len=0, void *value=0) { 
-            (*g_traceEntrypoints->m_traceCatch)(className,methodName,that,catchIndex,type,len,value); 
-    }
-#else
-    static inline void traceCatch(const char *className, const char *methodName, const void* that, int catchIndex,
-        int type=TRACETYPE_UNKNOWN, unsigned len=0, void *value=0) {
-        traceCatchInternal(className,methodName,that,catchIndex,type,len,value);
-    }
-#endif
-    static void traceCatchInternal(const char *className, const char *methodName, const void* that, int catchIndex,
-        int type=TRACETYPE_UNKNOWN, unsigned len=0, void *value=0);
-      /**
-       * Closes the trace file
-       */
-      static void terminate();
-
-      /**
-       * Returns the trace entrypoints to pass to a dynamically loaded library.
-       */
-#ifdef AXISTRACE_LIBRARY
-      static AxisTraceEntrypoints* getTraceEntrypoints() {
-          return g_traceEntrypoints;
-      }
-#elif !defined(AXIS_CLIENTC_LIB)
-      static AxisTraceEntrypoints* getTraceEntrypoints() {
-         return &g_traceEntrypoints;
-      }
-#endif
+#define logEntryTransport(lFunctionName) \
+logSetFunctionNameTransport(lFunctionName) \
+{ \
+  if (loggingEnabled) { \
+	  AxisTrace::writeEntry(logComponent, logFunctionName, NULL); \
+  } \
+}
 
-#ifdef AXISTRACE_LIBRARY
-      static void setTraceEntrypoints(AxisTraceEntrypoints* entrypoints) {
-          g_traceEntrypoints = entrypoints;
-      }
-#endif
+// ==================================================================================
+// Macros to simply use of exit tracing
+// ==================================================================================
 
-private:
+#define logExit() \
+{ \
+  if (loggingEnabled) { \
+	  AxisTrace::writeExit(logComponent, logFunctionName, NULL); \
+  } \
+}
 
-    static enum AxisTraceState m_bLoggingOn;
-    static AxisFile *m_fileTrace;
+#define logExitWithReturnCode(lRC) \
+{ \
+  if (loggingEnabled) { \
+	  AxisTrace::writeExit(logComponent, logFunctionName, "Exit with return code of %s", lRC == AXIS_SUCCESS ? "AXIS_SUCCESS" : "AXIS_FAIL"); \
+  } \
+}
 
-    static int logthis(const char* pcLog, int level, char* arg2, int arg3);
-    static void addParameter(std::string& line, int type, unsigned len, void *value);
-    static void addDataParameter(std::string& line, unsigned len, void *value);
-    static void traceHeader(enum AxisTraceState newState);
-    static void traceLine2(const char *data);
-    static int initialise(const char *filename, enum AxisTraceState newState);
-};
+#define logExitWithInteger(lint) \
+{ \
+  if (loggingEnabled) { \
+	  AxisTrace::writeExit(logComponent, logFunctionName, "Exit with integer value of %d", lint); \
+  } \
+}
 
-#ifdef ENABLE_AXISTRACE
-#define TRACE_OBJECT_CREATE_FUNCT_ENTRY(funct, size) \
+#define logExitWithPointer(lPointer) \
 { \
-    if (axiscpp::AxisTrace::isTraceOn()) \
-    { \
-        int traceSize = size; \
-        axiscpp::AxisTrace::traceEntry(NULL, "AXIS_OBJECT_CREATE_FUNCT", (void*)(funct), 1, \
-            TRACETYPE_INT, 1, (void*)&traceSize); \
-    } \
+  if (loggingEnabled) { \
+	  AxisTrace::writeExit(logComponent, logFunctionName, "Exit with object pointer %p", lPointer); \
+  } \
 }
 
-#define TRACE_OBJECT_CREATE_FUNCT_EXIT(funct, arr) \
+#define logExitWithString(lString) \
 { \
-    if (axiscpp::AxisTrace::isTraceOn()) \
-        axiscpp::AxisTrace::traceExit(NULL, "AXIS_OBJECT_CREATE_FUNCT", (void*)(funct), 1, \
-            TRACETYPE_POINTER, 1, (void*)&(arr)); \
+  if (loggingEnabled) { \
+	  AxisTrace::writeExit(logComponent, logFunctionName, "Exit with string \"%s\"", lString); \
+  } \
 }
 
-#define TRACE_OBJECT_DELETE_FUNCT_ENTRY(funct, arr, size) \
+#define logExitWithBoolean(lBoolean) \
 { \
-    if (axiscpp::AxisTrace::isTraceOn()) \
-    { \
-        void *traceArr = arr; \
-        int traceSize = size; \
-        axiscpp::AxisTrace::traceEntry(NULL, "AXIS_OBJECT_DELETE_FUNCT", (void*)(funct), 2, \
-            TRACETYPE_POINTER, 1, (void*)&traceArr, \
-            TRACETYPE_INT, 0, (void*)&traceSize); \
-    } \
+  if (loggingEnabled) { \
+	  AxisTrace::writeExit(logComponent, logFunctionName, "Exit with boolean %s", lBoolean ? "true" : "false"); \
+  } \
 }
 
-#define TRACE_OBJECT_DELETE_FUNCT_EXIT(funct) \
+#define logExitWithMessage(lfmt) \
 { \
-    if (axiscpp::AxisTrace::isTraceOn()) \
-        axiscpp::AxisTrace::traceExit(NULL, "AXIS_OBJECT_DELETE_FUNCT", (void*)(funct), 0); \
+  if (loggingEnabled) { \
+	  AxisTrace::writeExit(logComponent, logFunctionName, lfmt); \
+  } \
 }
 
-#define TRACE_DESERIALIZE_FUNCT_ENTRY(funct, item, that) \
+// ==================================================================================
+// Macros to simplify tracing thrown exceptions
+// ==================================================================================
+
+#define logThrowException(lException) \
 { \
-    if (axiscpp::AxisTrace::isTraceOn()) \
-    { \
-        void *traceItem = item; \
-        void *traceThat = that; \
-        axiscpp::AxisTrace::traceEntry(NULL, "AXIS_OBJECT_CREATE_FUNCT", (void*)(funct), 2, \
-            TRACETYPE_POINTER, 1, (void*)&traceItem, \
-            TRACETYPE_POINTER, 1, (void*)&traceThat); \
-    } \
+  if (loggingEnabled) { \
+	  AxisTrace::writeTrace(logComponent, TRACE_TYPE_EXCEPT, logFunctionName, __LINE__, __FILE__, lException); \
+	  AxisTrace::writeExit(logComponent, logFunctionName, NULL); \
+  } \
 }
 
-#define TRACE_DESERIALIZE_FUNCT_EXIT(funct, status) \
+#define logThrowExceptionWithData(lException, lExceptionMessage) \
 { \
-    if (axiscpp::AxisTrace::isTraceOn()) \
-        axiscpp::AxisTrace::traceExit(NULL, "AXIS_DESERIALIZE_FUNCT", (void*)(funct), 1, \
-            TRACETYPE_INT, 0, (void*)&(status)); \
+  if (loggingEnabled) { \
+	  AxisTrace::writeTrace(logComponent, TRACE_TYPE_EXCEPT, logFunctionName, __LINE__, __FILE__, "%s: %s", lException, lExceptionMessage); \
+	  AxisTrace::writeExit(logComponent, logFunctionName, NULL); \
+  } \
 }
 
-#define TRACE_SERIALIZE_FUNCT_ENTRY(funct, item, that, bArr) \
+#define logRethrowException() \
 { \
-    if (axiscpp::AxisTrace::isTraceOn()) \
-    { \
-        void *traceItem = item; \
-        void *traceThat = that; \
-        bool traceBArr = bArr; \
-        axiscpp::AxisTrace::traceEntry(NULL, "AXIS_SERIALIZE_FUNCT", (void*)(funct), 3, \
-            TRACETYPE_POINTER, 1, (void*)&traceItem, \
-            TRACETYPE_POINTER, 1, (void*)&traceThat, \
-            TRACETYPE_BOOL, 0, (void*)&traceBArr); \
-    } \
+  if (loggingEnabled) { \
+	  AxisTrace::writeExit(logComponent, logFunctionName, "%s", "Rethrowing exception"); \
+  } \
 }
 
-#define TRACE_SERIALIZE_FUNCT_EXIT(funct, status) \
+// ==================================================================================
+// Macros to simplify tracing
+// ==================================================================================
+
+#define logDebug(lFmt) \
 { \
-    if (axiscpp::AxisTrace::isTraceOn()) \
-        axiscpp::AxisTrace::traceExit(NULL, "AXIS_SERIALIZE_FUNCT", (void*)(funct), 1, \
-            TRACETYPE_INT, 0, (void*)&(status)); \
+  if (loggingEnabled) { \
+	  AxisTrace::writeTrace(logComponent, TRACE_TYPE_DEBUG, logFunctionName, lFmt); \
+  } \
 }
 
-#else
-#define TRACE_OBJECT_CREATE_FUNCT_ENTRY(funct, size)
-#define TRACE_OBJECT_CREATE_FUNCT_EXIT(funct, arr)
-#define TRACE_OBJECT_DELETE_FUNCT_ENTRY(funct, arr, size)
-#define TRACE_OBJECT_DELETE_FUNCT_EXIT(funct)
-#define TRACE_DESERIALIZE_FUNCT_ENTRY(funct, item, that)
-#define TRACE_DESERIALIZE_FUNCT_EXIT(funct, status)
-#define TRACE_SERIALIZE_FUNCT_ENTRY(funct, item, that, bArr)
-#define TRACE_SERIALIZE_FUNCT_EXIT(funct, status)
-#endif
+#define logDebugArg1(lFmt, lArg1) \
+{ \
+  if (loggingEnabled) { \
+	  AxisTrace::writeTrace(logComponent, TRACE_TYPE_DEBUG, logFunctionName, lFmt, lArg1); \
+  } \
+}
 
-AXIS_CPP_NAMESPACE_END
+#define logDebugArg2(lFmt, lArg1, lArg2) \
+{ \
+  if (loggingEnabled) { \
+	  AxisTrace::writeTrace(logComponent, TRACE_TYPE_DEBUG, logFunctionName, lFmt, lArg1, lArg2); \
+  } \
+}
+
+#define logDebugArg3(lFmt, lArg1, lArg2, lArg3) \
+{ \
+  if (loggingEnabled) { \
+	  AxisTrace::writeTrace(logComponent, TRACE_TYPE_DEBUG, logFunctionName, lFmt, lArg1, lArg2, lArg3); \
+  } \
+}
+
+#define logDebugArg4(lFmt, lArg1, lArg2, lArg3, lArg4) \
+{ \
+  if (loggingEnabled) { \
+	  AxisTrace::writeTrace(logComponent, TRACE_TYPE_DEBUG, logFunctionName, lFmt, lArg1, lArg2, lArg3, lArg4); \
+  } \
+}
+
+#define logDebugBuffer(lBuf, lBufLen) \
+{ \
+  if (loggingEnabled) { \
+	  AxisTrace::writeTrace(logComponent, TRACE_TYPE_DEBUG, logFunctionName, false, lBufLen, lBuf); \
+  } \
+}
+
+
+#define logWarning(lFmt) \
+{ \
+  if (loggingEnabled) { \
+	  AxisTrace::writeTrace(logComponent, TRACE_TYPE_WARN, logFunctionName, lFmt); \
+  } \
+}
 
 #endif
 

Modified: webservices/axis/trunk/c/src/common/AxisUtils.cpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/common/AxisUtils.cpp?rev=713841&r1=713840&r2=713841&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/common/AxisUtils.cpp (original)
+++ webservices/axis/trunk/c/src/common/AxisUtils.cpp Thu Nov 13 14:13:23 2008
@@ -170,6 +170,8 @@
 
 IAnySimpleType* AxisUtils::createSimpleTypeObject(void * pValue, XSDTYPE type)
 {
+	logEntryEngine("AxisUtils::createSimpleTypeObject")
+
     IAnySimpleType* xsdValue = NULL;
     
     // Put commonly used type at top of switch statement!
@@ -314,6 +316,8 @@
             break;
     }
     
+    logExitWithPointer(xsdValue)
+    
     return xsdValue;
 }
 

Modified: webservices/axis/trunk/c/src/common/BasicTypeSerializer.cpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/common/BasicTypeSerializer.cpp?rev=713841&r1=713840&r2=713841&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/common/BasicTypeSerializer.cpp (original)
+++ webservices/axis/trunk/c/src/common/BasicTypeSerializer.cpp Thu Nov 13 14:13:23 2008
@@ -33,33 +33,50 @@
 
 AXIS_CPP_NAMESPACE_START
 
-BasicTypeSerializer::BasicTypeSerializer ()
+BasicTypeSerializer::
+BasicTypeSerializer ()
 {
+	logEntryEngine("BasicTypeSerializer::BasicTypeSerializer")
+
     m_sSZ = "";
+    
+    logExit()
 }
 
-BasicTypeSerializer::~BasicTypeSerializer ()
+BasicTypeSerializer::
+~BasicTypeSerializer ()
 {
+	logEntryEngine("BasicTypeSerializer::~BasicTypeSerializer")
 
+    logExit()
 }
 
-const AxisChar* BasicTypeSerializer::serializeAsElement (const AxisChar* pName,
-    IAnySimpleType* pSimpleType)
+const AxisChar* BasicTypeSerializer::
+serializeAsElement (const AxisChar* pName,
+                    IAnySimpleType* pSimpleType)
 {
 	return serializeAsElement(pName, NULL, pSimpleType);
 }
 
-const AxisChar* BasicTypeSerializer::serializeAsElement (const AxisChar* pName,
-    const AxisChar* pPrefix, IAnySimpleType* pSimpleType)
+const AxisChar* BasicTypeSerializer::
+serializeAsElement (const AxisChar* pName,
+                    const AxisChar* pPrefix, 
+                    IAnySimpleType* pSimpleType)
 {
     return serializeAsElement(pName, pPrefix, NULL, pSimpleType);
 }
 
-const AxisChar* BasicTypeSerializer::serializeAsElement (const AxisChar* pName,
-    const AxisChar* pPrefix, const AxisChar* pNamespace, IAnySimpleType* pSimpleType)
+const AxisChar* BasicTypeSerializer::
+serializeAsElement (const AxisChar* pName,
+                    const AxisChar* pPrefix, 
+                    const AxisChar* pNamespace, 
+                    IAnySimpleType* pSimpleType)
 {
+	logEntryEngine("BasicTypeSerializer::serializeAsElement")
+
     m_sSZ = "<";
-	if (NULL != pPrefix) { 
+	if (NULL != pPrefix) 
+	{ 
 		m_sSZ += pPrefix;
 		m_sSZ += ":";
 	}
@@ -107,23 +124,29 @@
         m_sSZ += " xsi:nil=\"true\">";
     }
     else
-    {
         m_sSZ += pSimpleType->serialize();
-    }
+    
     m_sSZ += "</";
-	if (NULL != pPrefix) {
+	if (NULL != pPrefix) 
+	{
 		m_sSZ += pPrefix;
 		m_sSZ += ":";
 	}
     m_sSZ += pName;
     m_sSZ += ">\n";
+    
+    logExitWithString(m_sSZ.c_str ())
+    
     return m_sSZ.c_str ();
 }
 
-const AxisChar* BasicTypeSerializer::serializeAsAttribute 
-    (const AxisChar* pName, const AxisChar* pPrefix,
-    IAnySimpleType* pSimpleType)
+const AxisChar* BasicTypeSerializer::
+serializeAsAttribute (const AxisChar* pName, 
+		              const AxisChar* pPrefix,
+                      IAnySimpleType* pSimpleType)
 {
+	logEntryEngine("BasicTypeSerializer::serializeAsAttribute")
+
     m_sSZ = ' ';
     if (pPrefix)
     {
@@ -137,10 +160,14 @@
     m_sSZ += pSimpleType->serialize();
 
     m_sSZ += '"';
+    
+    logExitWithString(m_sSZ.c_str ())
+
     return m_sSZ.c_str ();
 }
 
-const AxisChar* BasicTypeSerializer::basicTypeStr (XSDTYPE type)
+const AxisChar* BasicTypeSerializer::
+basicTypeStr (XSDTYPE type)
 {
     switch (type)
     {

Modified: webservices/axis/trunk/c/src/common/MessageData.cpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/common/MessageData.cpp?rev=713841&r1=713840&r2=713841&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/common/MessageData.cpp (original)
+++ webservices/axis/trunk/c/src/common/MessageData.cpp Thu Nov 13 14:13:23 2008
@@ -36,17 +36,24 @@
 const AxisChar* MessageData::m_pachBlankPropertyValue = "";
 AdminUtils MessageData::m_AdminUtil;
 
-MessageData::MessageData ()
+MessageData::
+MessageData ()
 {
+	logEntryEngine("MessageData::MessageData")
+
     m_pSZ = NULL;
     m_pDZ = NULL;
     m_bPastPivotState = false;
+    
+    logExit()
 }
 
-MessageData::~MessageData ()
+MessageData::
+~MessageData ()
 {
-    map < const AxisChar*, const AxisChar*, ltstr >::const_iterator itCurrentItem =
-        m_Properties.begin ();
+	logEntryEngine("MessageData::~MessageData")
+
+    map < const AxisChar*, const AxisChar*, ltstr >::const_iterator itCurrentItem = m_Properties.begin ();
 
     while (itCurrentItem != m_Properties.end ())
     {
@@ -57,92 +64,94 @@
     }
 
     m_Properties.clear ();
+    
+    logExit()
 }
 
-void MessageData::setSerializer (IWrapperSoapSerializer* pSZ)
+void MessageData::
+setSerializer (IWrapperSoapSerializer* pSZ)
 {
     m_pSZ = pSZ;
 }
 
-void MessageData::setDeSerializer (IWrapperSoapDeSerializer* pDZ)
+void MessageData::
+setDeSerializer (IWrapperSoapDeSerializer* pDZ)
 {
     m_pDZ = pDZ;
 }
 
-void MessageData::setOperationName(const AxisChar* pchOperation)
+void MessageData::
+setOperationName(const AxisChar* pchOperation)
 {
 	m_sOperationName = pchOperation;
 }
-const AxisChar* MessageData::getOperationName()
+const AxisChar* MessageData::
+getOperationName()
 {
 	return m_sOperationName.c_str();
 }
 
-void MessageData::setUserName (string &sUserName)
+void MessageData::
+setUserName (string &sUserName)
 {
     m_sUserName = sUserName;
 }
 
-string &MessageData::getUserName ()
+string &MessageData::
+getUserName ()
 {
     return m_sUserName;
-    // return "damitha kumarage"; 
 }
 
-/*
- *    comm on 25Jul2003 at 10.00am
- *    ISoapSerializer* MessageData::getSoapSerializer()
- *    {
- *        return m_pSZ;
- *    }
- */
-
-IWrapperSoapDeSerializer* MessageData::getSoapDeserializer ()
+IWrapperSoapDeSerializer* MessageData::
+getSoapDeserializer ()
 {
     return m_pDZ;
 }
 
-bool MessageData::isPastPivot ()
+bool MessageData::
+isPastPivot ()
 {
     return m_bPastPivotState;
 }
 
-int MessageData::setPastPivotState (bool bState)
+int MessageData::
+setPastPivotState (bool bState)
 {
     m_bPastPivotState = bState;
 
     return AXIS_SUCCESS;
 }
 
-void MessageData::getSoapSerializer 
-    (IHandlerSoapSerializer** pIHandlerSoapSerializer)
+void MessageData::
+getSoapSerializer (IHandlerSoapSerializer** pIHandlerSoapSerializer)
 {
     *pIHandlerSoapSerializer = static_cast < IHandlerSoapSerializer* >(m_pSZ);
 }
 
-void MessageData::getSoapSerializer (IWrapperSoapSerializer**
-    pIWrapperSoapSerializer)
+void MessageData::
+getSoapSerializer (IWrapperSoapSerializer** pIWrapperSoapSerializer)
 {
     *pIWrapperSoapSerializer = static_cast < IWrapperSoapSerializer* >(m_pSZ);
 }
 
-void MessageData::getSoapDeSerializer (IWrapperSoapDeSerializer**
-    pIWrapperSoapDeSerializer)
+void MessageData::
+getSoapDeSerializer (IWrapperSoapDeSerializer** pIWrapperSoapDeSerializer)
 {
-    *pIWrapperSoapDeSerializer = 
-        static_cast < IWrapperSoapDeSerializer* >(m_pDZ);
+    *pIWrapperSoapDeSerializer = static_cast < IWrapperSoapDeSerializer* >(m_pDZ);
 }
 
-void MessageData::getSoapDeSerializer (IHandlerSoapDeSerializer**
-    pIHandlerSoapDeSerializer)
+void MessageData::
+getSoapDeSerializer (IHandlerSoapDeSerializer** pIHandlerSoapDeSerializer)
 {
-    *pIHandlerSoapDeSerializer = 
-        static_cast < IHandlerSoapDeSerializer * >(m_pDZ);
+    *pIHandlerSoapDeSerializer = static_cast < IHandlerSoapDeSerializer * >(m_pDZ);
 }
 
 
 
-int MessageData::setProperty (const AxisChar* pachName, const AxisChar* pachValue)
+int MessageData::
+setProperty (const AxisChar* pachName, 
+		     const AxisChar* pachValue)
 {
     AxisChar* pachTmpName = new AxisChar[strlen (pachName) + 1];
     strcpy (pachTmpName, pachName);
@@ -154,7 +163,10 @@
     return AXIS_SUCCESS;
 }
 
-int MessageData::setProperty (const AxisChar* pachName, const void* pachValue, int len)
+int MessageData::
+setProperty (const AxisChar* pachName, 
+		     const void* pachValue, 
+		     int len)
 {
      AxisChar* pachTmpName = new AxisChar[strlen (pachName) + 1];
      strcpy (pachTmpName, pachName);
@@ -166,7 +178,10 @@
      return AXIS_SUCCESS;
 }
 
-void MessageData::setComplexProperty(const AxisChar* pachName, void* pValue, int iObjectSize)
+void MessageData::
+setComplexProperty(const AxisChar* pachName, 
+		           void* pValue, 
+		           int iObjectSize)
 {
     AxisChar* pachTmpName = new AxisChar[strlen (pachName) + 1];
     strcpy (pachTmpName, pachName);
@@ -181,7 +196,8 @@
  *    not. If it is empty then the idea is that the property is not 
  *    available.
  */
-const void* MessageData::getProperty (const AxisChar* pachName)
+const void* MessageData::
+getProperty (const AxisChar* pachName)
 {
     if (m_Properties.find (pachName) != m_Properties.end ())
     {
@@ -191,7 +207,8 @@
     return m_pachBlankPropertyValue;
 }
 
-void* MessageData::getComplexProperty(const AxisChar* pachName)
+void* MessageData::
+getComplexProperty(const AxisChar* pachName)
 {
     if (m_ComplexProperties.find (pachName) != m_ComplexProperties.end ())
     {
@@ -201,7 +218,8 @@
     return NULL;	
 }
 
-void MessageData::getAdminUtils (IAdminUtils** pIAdminUtils)
+void MessageData::
+getAdminUtils (IAdminUtils** pIAdminUtils)
 {
     *pIAdminUtils = &m_AdminUtil;
 }