activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r543121 [5/6] - in /activemq/activemq-cpp/trunk/src/decaf: io/ lang/ lang/exceptions/ net/ util/ util/concurrent/ util/logging/
Date Thu, 31 May 2007 11:56:03 GMT
Added: activemq/activemq-cpp/trunk/src/decaf/util/concurrent/Mutex.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/util/concurrent/Mutex.cpp?view=auto&rev=543121
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/util/concurrent/Mutex.cpp (added)
+++ activemq/activemq-cpp/trunk/src/decaf/util/concurrent/Mutex.cpp Thu May 31 04:55:59 2007
@@ -0,0 +1,263 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <decaf/util/concurrent/Mutex.h>
+
+using namespace decaf;
+using namespace decaf::util;
+using namespace decaf::util::concurrent;
+
+////////////////////////////////////////////////////////////////////////////////
+Mutex::Mutex()
+{
+#ifdef HAVE_PTHREAD_H
+    pthread_mutexattr_t attr;
+    pthread_mutexattr_init(&attr);
+    pthread_mutex_init(&mutex, &attr);
+    pthread_mutexattr_destroy(&attr);
+#else
+    InitializeCriticalSection(&mutex);
+#endif
+
+    lock_owner = 0;
+    lock_count = 0;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Mutex::~Mutex()
+{
+    // Unlock the mutex.
+    unlock();
+
+#ifdef HAVE_PTHREAD_H
+    pthread_mutex_destroy(&mutex);
+#else
+    DeleteCriticalSection(&mutex);
+#endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Mutex::lock() throw( lang::Exception )
+{
+    if(isLockOwner())
+    {
+        lock_count++;
+    }
+    else
+    {
+#ifdef HAVE_PTHREAD_H
+        pthread_mutex_lock(&mutex);
+#else
+        EnterCriticalSection(&mutex);
+#endif
+
+        lock_count = 1;
+        lock_owner = Thread::getId();
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Mutex::unlock() throw( lang::Exception )
+{
+    if(lock_owner == 0)
+    {
+        return;
+    }
+
+    if(!isLockOwner())
+    {
+        throw lang::ActiveMQException(
+            __FILE__, __LINE__,
+            "Mutex::unlock - Failed, not Lock Owner!" );
+    }
+
+    lock_count--;
+
+    if(lock_count == 0)
+    {
+        lock_owner = 0;
+
+#ifdef HAVE_PTHREAD_H
+        pthread_mutex_unlock(&mutex);
+#else
+        LeaveCriticalSection(&mutex);
+#endif
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Mutex::wait() throw( lang::Exception )
+{
+    // Delegate to the timed version
+    wait( WAIT_INFINITE );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Mutex::wait( unsigned long millisecs )
+    throw( lang::Exception )
+{
+    if(!isLockOwner())
+    {
+        throw lang::Exception(
+            __FILE__, __LINE__,
+            "Mutex::wait - Failed, not Lock Owner!");
+    }
+
+    // Save the current owner and Lock count as we are going to
+    // unlock and release for someone else to lock on potentially.
+    // When we come back and re-lock we want to restore to the
+    // state we were in before.
+    unsigned long lock_owner = this->lock_owner;
+    int           lock_count = this->lock_count;
+
+    this->lock_count = 0;
+    this->lock_owner = 0;
+
+#ifdef HAVE_PTHREAD_H
+
+    // Create this threads wait event
+    pthread_cond_t waitEvent;
+    pthread_cond_init(&waitEvent, NULL);
+
+    // Store the event in the queue so that a notify can
+    // call it and wake up the thread.
+    eventQ.push_back(&waitEvent);
+
+    int returnValue = 0;
+    if(millisecs != WAIT_INFINITE)
+    {
+        timeval now = {0,0};
+        gettimeofday(&now, NULL);
+
+        timespec wait = {0,0};
+        wait.tv_sec = now.tv_sec + (millisecs / 1000);
+        wait.tv_nsec = (now.tv_usec * 1000) + ((millisecs % 1000) * 1000000);
+
+        if(wait.tv_nsec > 1000000000)
+        {
+            wait.tv_sec++;
+            wait.tv_nsec -= 1000000000;
+        }
+
+        returnValue =  pthread_cond_timedwait(&waitEvent, &mutex, &wait);
+    }
+    else
+    {
+        returnValue = pthread_cond_wait(&waitEvent, &mutex);
+    }
+
+    // If the wait did not succeed for any reason, remove it
+    // from the queue.
+    if( returnValue != 0 ){
+        std::list<pthread_cond_t*>::iterator iter = eventQ.begin();
+        for( ; iter != eventQ.end(); ++iter ){
+            if( *iter == &waitEvent ){
+                eventQ.erase(iter);
+                break;
+            }
+        }
+    }
+
+    // Destroy our wait event now, the notify method will have removed it
+    // from the event queue.
+    pthread_cond_destroy(&waitEvent);
+
+#else // !defined(HAVE_PTHREAD_H)
+
+    // Create the event to wait on
+    HANDLE waitEvent = CreateEvent( NULL, false, false, NULL );
+
+    if(waitEvent == NULL)
+    {
+        throw lang::Exception(
+            __FILE__, __LINE__,
+            "Mutex::Mutex - Failed Creating Event." );
+    }
+
+    eventQ.push_back( waitEvent );
+
+    // Release the Lock
+    LeaveCriticalSection( &mutex );
+
+    // Wait for a signal
+    WaitForSingleObject( waitEvent, millisecs );
+
+    // Reaquire the Lock
+    EnterCriticalSection( &mutex );
+
+    // Clean up the event, the notif methods will have
+    // already poped it from the queue.
+    CloseHandle( waitEvent );
+
+#endif // !defined(HAVE_PTHREAD_H)
+
+    // restore the owner
+    this->lock_owner = lock_owner;
+    this->lock_count = lock_count;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Mutex::notify() throw( lang::Exception )
+{
+    if( !isLockOwner() )
+    {
+        throw lang::Exception(
+            __FILE__, __LINE__,
+            "Mutex::Notify - Failed, not Lock Owner!" );
+    }
+
+    if( !eventQ.empty() )
+    {
+#ifdef HAVE_PTHREAD_H
+        pthread_cond_signal( eventQ.front() );
+        eventQ.pop_front();
+#else
+        SetEvent( eventQ.front() );
+        eventQ.pop_front();
+#endif
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Mutex::notifyAll() throw( lang::Exception )
+{
+    if(!isLockOwner())
+    {
+        throw lang::Exception(
+            __FILE__, __LINE__,
+            "Mutex::NotifyAll - Failed, not Lock Owner!" );
+    }
+
+#ifdef HAVE_PTHREAD_H
+
+    while(!eventQ.empty())
+    {
+         pthread_cond_signal( eventQ.front() );
+         eventQ.pop_front();
+    }
+
+#else
+
+    while(!eventQ.empty())
+    {
+         SetEvent( eventQ.front() );
+         eventQ.pop_front();
+    }
+
+#endif
+}
+

Added: activemq/activemq-cpp/trunk/src/decaf/util/concurrent/Mutex.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/util/concurrent/Mutex.h?view=auto&rev=543121
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/util/concurrent/Mutex.h (added)
+++ activemq/activemq-cpp/trunk/src/decaf/util/concurrent/Mutex.h Thu May 31 04:55:59 2007
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DECAF_UTIL_CONCURRENT_MUTEX_H_
+#define _DECAF_UTIL_CONCURRENT_MUTEX_H_
+
+// Includes.
+#include <decaf/util/concurrent/Synchronizable.h>
+#include <decaf/util/concurrent/Concurrent.h>
+#include <decaf/lang/Thread.h>
+#include <decaf/util/Config.h>
+#include <list>
+
+#ifdef HAVE_SYS_TIME_H
+    #include <sys/time.h>
+#endif
+
+#ifdef HAVE_PTHREAD_H
+    #include <pthread.h>
+#else
+    #include <windows.h>
+
+    #if ( !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0400)
+        #if ( !defined(WINVER) || WINVER < 0x0400)
+            #pragma message ("Unsupported platform, Windows NT 4.0 or later required")
+        #endif
+    #endif
+
+#endif
+
+#include <assert.h>
+
+namespace decaf{
+namespace util{
+namespace concurrent{
+
+    /**
+     * Creates a pthread_mutex_t object. The object is created
+     * such that successive locks from the same thread is allowed
+     * and will be successful.
+     * @see  pthread_mutex_t
+     */
+    class AMQCPP_API Mutex : public Synchronizable
+    {
+    private:       // Data
+
+        /**
+         * The mutex object.
+         */
+        #ifdef HAVE_PTHREAD_H
+            pthread_mutex_t mutex;
+
+            std::list<pthread_cond_t*> eventQ;
+        #else
+            CRITICAL_SECTION mutex;
+
+            std::list<HANDLE> eventQ;
+        #endif
+
+        // Lock Status Members
+        int           lock_count;
+        unsigned long lock_owner;
+
+    public:
+
+        /**
+         * Constructor - creates and initializes the mutex.
+         */
+        Mutex();
+
+        /**
+         * Destructor - destroys the mutex object.
+         */
+        virtual ~Mutex();
+
+        /**
+         * Locks the object.
+         * @throws ActiveMQException
+         */
+        virtual void lock() throw( lang::Exception );
+
+        /**
+         * Unlocks the object.
+         * @throws ActiveMQException
+         */
+        virtual void unlock() throw( lang::Exception );
+
+        /**
+         * Waits on a signal from this object, which is generated
+         * by a call to Notify.
+         * @throws ActiveMQException
+         */
+        virtual void wait() throw( lang::Exception );
+
+        /**
+         * Waits on a signal from this object, which is generated
+         * by a call to Notify.  Must have this object locked before
+         * calling.  This wait will timeout after the specified time
+         * interval.
+         * @param millisecs the time in milliseconds to wait.
+         * @throws ActiveMQException
+         */
+        virtual void wait( unsigned long millisecs )
+            throw( lang::Exception );
+
+        /**
+         * Signals a waiter on this object that it can now wake
+         * up and continue.
+         * @throws ActiveMQException
+         */
+        virtual void notify() throw( lang::Exception );
+
+        /**
+         * Signals the waiters on this object that it can now wake
+         * up and continue.
+         * @throws ActiveMQException
+         */
+        virtual void notifyAll() throw( lang::Exception );
+
+    private:
+
+        /**
+         * Check if the calling thread is the Lock Owner
+         * @retuns true if the caller is the lock owner
+         */
+        bool isLockOwner()
+        {
+            return lock_owner == lang::Thread::getId();
+        }
+
+    };
+
+}}}
+
+#endif // _DECAF_UTIL_CONCURRENT_MUTEX_H_

Added: activemq/activemq-cpp/trunk/src/decaf/util/concurrent/Synchronizable.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/util/concurrent/Synchronizable.h?view=auto&rev=543121
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/util/concurrent/Synchronizable.h (added)
+++ activemq/activemq-cpp/trunk/src/decaf/util/concurrent/Synchronizable.h Thu May 31 04:55:59 2007
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DECAF_UTIL_CONCURRENT_SYNCHRONIZABLE_H_
+#define _DECAF_UTIL_CONCURRENT_SYNCHRONIZABLE_H_
+
+#include <decaf/lang/Exception.h>
+#include <decaf/util/Config.h>
+
+namespace decaf{
+namespace util{
+namespace concurrent{
+
+    /**
+     * The interface for all synchronizable objects (that is, objects
+     * that can be locked and unlocked).
+     */
+    class Synchronizable
+    {
+    public:
+
+        virtual ~Synchronizable(){}
+
+        /**
+         * Locks the object.
+         * @throws Exception
+         */
+        virtual void lock() throw( lang::Exception ) = 0;
+
+        /**
+         * Unlocks the object.
+         * @throws Exception
+         */
+        virtual void unlock() throw( lang::Exception ) = 0;
+
+        /**
+         * Waits on a signal from this object, which is generated
+         * by a call to Notify.  Must have this object locked before
+         * calling.
+         * @throws Exception
+         */
+        virtual void wait() throw( lang::Exception ) = 0;
+
+        /**
+         * Waits on a signal from this object, which is generated
+         * by a call to Notify.  Must have this object locked before
+         * calling.  This wait will timeout after the specified time
+         * interval.
+         * @param millisecs the time in millisecsonds to wait, or
+         * WAIT_INIFINITE
+         * @throws Exception
+         */
+        virtual void wait(unsigned long millisecs)
+            throw( lang::Exception ) = 0;
+
+        /**
+         * Signals a waiter on this object that it can now wake
+         * up and continue.  Must have this object locked before
+         * calling.
+         * @throws Exception
+         */
+        virtual void notify() throw( lang::Exception ) = 0;
+
+        /**
+         * Signals the waiters on this object that it can now wake
+         * up and continue.  Must have this object locked before
+         * calling.
+         * @throws Exception
+         */
+        virtual void notifyAll() throw( lang::Exception ) = 0;
+
+    };
+
+}}}
+
+#endif /*_DECAF_UTIL_CONCURRENT_SYNCHRONIZABLE_H_*/

Added: activemq/activemq-cpp/trunk/src/decaf/util/logging/ConsoleHandler.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/util/logging/ConsoleHandler.h?view=auto&rev=543121
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/util/logging/ConsoleHandler.h (added)
+++ activemq/activemq-cpp/trunk/src/decaf/util/logging/ConsoleHandler.h Thu May 31 04:55:59 2007
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef _DECAF_UTIL_LOGGING_CONSOLEHANDLER_H_
+#define _DECAF_UTIL_LOGGING_CONSOLEHANDLER_H_
+
+#include <decaf/util/logging/StreamHandler.h>
+#include <activemq/io/StandardErrorOutputStream.h>
+
+namespace decaf{
+namespace util{
+namespace logging{
+
+    /**
+     * This Handler publishes log records to System.err. By default the
+     * SimpleFormatter is used to generate brief summaries.
+     *
+     * Configuration: By default each ConsoleHandler is initialized using
+     * the following LogManager configuration properties. If properties are
+     * not defined (or have invalid values) then the specified default
+     * values are used.
+     *
+     * ConsoleHandler.level specifies the default level for the Handler
+     *  (defaults to Level.INFO).
+     * ConsoleHandler.filter specifies the name of a Filter class to use
+     *  (defaults to no Filter).
+     * ConsoleHandler.formatter specifies the name of a Formatter class to
+     *  use (defaults to SimpleFormatter).
+     */
+    class ConsoleHandler : public StreamHandler {
+    private:
+
+        // The Standard Error Stream to log to
+        io::StandardErrorOutputStream stream;
+
+        // The default Simple Formatter
+        SimpleFormatter formatter;
+
+    public:
+
+        ConsoleHandler() : StreamHandler( &stream, &formatter ) {
+
+            // Defaults level to Info
+            setLevel( Level.INFO );
+        }
+
+        virtual ~ConsoleHandler() {}
+
+        /**
+         * Close the current output stream.
+         * <p>
+         * Override the StreamHandler close to flush the Std Err stream
+         * but doesn't close.
+         * @throw CMSException
+         */
+        virtual void close() throw ( cms::CMSException )
+        {
+            if( getOutputStream() ) {
+                getOutputStream->flush();
+            }
+        }
+
+    };
+
+}})
+
+#endif /*_DECAF_UTIL_LOGGING_CONSOLEHANDLER_H_*/

Added: activemq/activemq-cpp/trunk/src/decaf/util/logging/Filter.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/util/logging/Filter.h?view=auto&rev=543121
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/util/logging/Filter.h (added)
+++ activemq/activemq-cpp/trunk/src/decaf/util/logging/Filter.h Thu May 31 04:55:59 2007
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef _DECAF_UTIL_LOGGING_FILTER_H_
+#define _DECAF_UTIL_LOGGING_FILTER_H_
+
+#include <decaf/util/logging/LogRecord.h>
+
+namespace decaf{
+namespace util{
+namespace logging{
+
+    /**
+     * A Filter can be used to provide fine grain control over what is
+     * logged, beyond the control provided by log levels.
+     *
+     * Each Logger and each Handler can have a filter associated with it.
+     * The Logger or Handler will call the isLoggable method to check if a
+     * given LogRecord should be published. If isLoggable returns false,
+     * the LogRecord will be discarded.
+     */
+    class Filter {
+    public:
+
+        virtual ~Filter() {}
+
+        /**
+         * Check if a given log record should be published.
+         * @param record the <code>LogRecord</code> to check.
+         * @returns true if the record is loggable.
+         */
+        virtual bool isLoggable( const LogRecord& record ) const = 0;
+
+    };
+
+}}}
+
+#endif /*_DECAF_UTIL_LOGGING_FILTER_H_*/

Added: activemq/activemq-cpp/trunk/src/decaf/util/logging/Formatter.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/util/logging/Formatter.h?view=auto&rev=543121
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/util/logging/Formatter.h (added)
+++ activemq/activemq-cpp/trunk/src/decaf/util/logging/Formatter.h Thu May 31 04:55:59 2007
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef _DECAF_UTIL_LOGGING_FORMATTER_H_
+#define _DECAF_UTIL_LOGGING_FORMATTER_H_
+
+namespace decaf{
+namespace util{
+namespace logging{
+
+    /**
+     * A Formatter provides support for formatting LogRecords.
+     *
+     * Typically each logging Handler will have a Formatter associated with
+     * it. The Formatter takes a LogRecord and converts it to a string.
+     *
+     * Some formatters (such as the XMLFormatter) need to wrap head and
+     * tail strings around a set of formatted records. The getHeader and
+     * getTail methods can be used to obtain these strings.
+     */
+    class Formatter {
+    public:
+
+        virtual ~Formatter() {}
+
+        /**
+         * Format the given log record and return the formatted string.
+         * @param record The Log Record to Format
+         * @returns the formatted record.
+         */
+        virtual std::string format( const LogRecord& record ) const = 0;
+
+        /**
+         * Format the message string from a log record.
+         * @param record The Log Record to Format
+         * @returns the formatted message
+         */
+        virtual std::string formatMessage( const LogRecord& record ) const = 0;
+
+        /**
+         * Return the header string for a set of formatted records.  In the
+         * default implementation this method should return empty string
+         * @param handler the target handler, can be null
+         * @return the head string
+         */
+        virtual std::string getHead( const Handler* handler ) = 0;
+
+        /**
+         * Return the tail string for a set of formatted records.  In the
+         * default implementation this method should return empty string
+         * @param handler the target handler, can be null
+         * @return the tail string
+         */
+        virtual std::string getTail( const Handler* handler ) = 0;
+
+    };
+
+}}}
+
+#endif /*_DECAF_UTIL_LOGGING_FORMATTER_H_*/

Added: activemq/activemq-cpp/trunk/src/decaf/util/logging/Handler.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/util/logging/Handler.h?view=auto&rev=543121
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/util/logging/Handler.h (added)
+++ activemq/activemq-cpp/trunk/src/decaf/util/logging/Handler.h Thu May 31 04:55:59 2007
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef _DECAF_UTIL_LOGGING_HANDLER_H_
+#define _DECAF_UTIL_LOGGING_HANDLER_H_
+
+#include <cms/Closeable.h>
+#include <decaf/util/logging/LogRecord.h>
+
+namespace decaf{
+namespace util{
+namespace logging{
+
+    class Filter;
+    class Formatter;
+
+    /**
+     * A Handler object takes log messages from a Logger and exports them.
+     * It might for example, write them to a console or write them to a file,
+     * or send them to a network logging service, or forward them to an OS
+     * log, or whatever.
+     *
+     * A Handler can be disabled by doing a setLevel(Level.OFF) and can be
+     * re-enabled by doing a setLevel with an appropriate level.
+     *
+     * Handler classes typically use LogManager properties to set default
+     * values for the Handler's Filter, Formatter, and Level. See the
+     * specific documentation for each concrete Handler class.
+     */
+    class Handler : public cms::Closeable {
+    public:
+
+        virtual ~Handler() {}
+
+        /**
+         * Flush the Handler's output, clears any buffers.
+         */
+        virtual void flush() = 0;
+
+        /**
+         * Publish the Log Record to this Handler
+         * @param record The Log Record to Publish
+         */
+        virtual void publish( const LogRecord& record ) = 0;
+
+        /**
+         * Check if this Handler would actually log a given LogRecord.
+         * <p>
+         * This method checks if the LogRecord has an appropriate Level and
+         * whether it satisfies any Filter. It also may make other Handler
+         * specific checks that might prevent a handler from logging the
+         * LogRecord.
+         * @param record <code>LogRecord</code> to check
+         */
+        virtual void isLoggable( const LogRecord& record ) = 0;
+
+        /**
+         * Sets the Filter that this Handler uses to filter Log Records
+         * <p>
+         * For each call of publish the Handler will call this Filter (if it
+         * is non-null) to check if the LogRecord should be published or
+         * discarded.
+         * @param filter <code>Filter</code> derived instance
+         */
+        virtual void setFilter( const Filter* filter ) = 0;
+
+        /**
+         * Gets the Filter that this Handler uses to filter Log Records
+         * @returns <code>Filter</code> derived instance
+         */
+        virtual const Filter* getFilter() = 0;
+
+        /**
+         * Set the log level specifying which message levels will be logged
+         * by this Handler.
+         * <p>
+         * The intention is to allow developers to turn on voluminous logging,
+         * but to limit the messages that are sent to certain Handlers.
+         * @param value Level enumeration value
+         */
+        virtual void setLevel( Level value ) = 0;
+
+        /**
+         * Get the log level specifying which message levels will be logged
+         * by this Handler.
+         * @returns Level enumeration value
+         */
+        virtual Level getLevel() = 0;
+
+        /**
+         * Sets the <code>Formatter</code> used by this Handler
+         * <p>
+         * Some Handlers may not use Formatters, in which case the
+         * Formatter will be remembered, but not used.
+         * @param formatter <code>Filter</code> derived instance
+         */
+        virtual void setFormatter( const Formatter* formatter ) = 0;
+
+        /**
+         * Gets the <code>Formatter</code> used by this Handler
+         * @returns <code>Filter</code> derived instance
+         */
+        virtual const Formatter* getFormatter() = 0;
+
+   };
+
+}}}
+
+#endif /*_DECAF_UTIL_LOGGING_HANDLER_H_*/

Added: activemq/activemq-cpp/trunk/src/decaf/util/logging/LogManager.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/util/logging/LogManager.cpp?view=auto&rev=543121
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/util/logging/LogManager.cpp (added)
+++ activemq/activemq-cpp/trunk/src/decaf/util/logging/LogManager.cpp Thu May 31 04:55:59 2007
@@ -0,0 +1,121 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#include "LogManager.h"
+
+#include <decaf/util/logging/PropertiesChangeListener.h>
+#include <activemq/concurrent/Concurrent.h>
+#include <activemq/util/Config.h>
+
+#include <algorithm>
+
+using namespace std;
+using namespace activemq;
+using namespace activemq::util;
+using namespace decaf::util::logging;
+
+////////////////////////////////////////////////////////////////////////////////
+concurrent::Mutex LogManager::mutex;
+LogManager* LogManager::instance = NULL;
+unsigned int LogManager::refCount = 0;
+
+////////////////////////////////////////////////////////////////////////////////
+LogManager::~LogManager()
+{
+    // TODO - Delete all the loggers.
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void LogManager::setProperties( const Properties* properties )
+{
+    // Copy the properties
+    this->properties.copy(properties);
+
+    // Update the configuration of the loggers.
+    // TODO
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void LogManager::addPropertyChangeListener(
+    PropertyChangeListener* listener )
+{
+    if( find(listeners.begin(), listeners.end(), listener) == listeners.end() ) {
+        listeners.push_back( listener );
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void LogManager::removePropertyChangeListener(
+    PropertyChangeListener* listener )
+{
+    listeners.remove( listener );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Logger* LogManager::getLogger( const std::string& name AMQCPP_UNUSED ) {
+    return NULL;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int LogManager::getLoggerNames( const std::vector<std::string>& names  AMQCPP_UNUSED ) {
+    return 0;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+LogManager* LogManager::getInstance() {
+
+    synchronized( &mutex ) {
+        if( instance == NULL ) {
+            instance = new LogManager();
+        }
+
+        refCount++;
+
+        return instance;
+    }
+
+    return NULL;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void LogManager::returnInstance() {
+
+    synchronized( &mutex ) {
+        if( refCount == 0 ) {
+            return ;
+        }
+
+        refCount--;
+
+        if( refCount == 0 ) {
+            delete instance;
+            instance = NULL;
+        }
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void LogManager::destroy()
+{
+    if( instance != NULL ) {
+
+        synchronized( &mutex ) {
+            delete instance;
+            instance = NULL;
+            refCount = 0;
+        }
+    }
+}

Added: activemq/activemq-cpp/trunk/src/decaf/util/logging/LogManager.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/util/logging/LogManager.h?view=auto&rev=543121
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/util/logging/LogManager.h (added)
+++ activemq/activemq-cpp/trunk/src/decaf/util/logging/LogManager.h Thu May 31 04:55:59 2007
@@ -0,0 +1,251 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#ifndef _DECAF_UTIL_LOGGING_LOGMANAGER_H_
+#define _DECAF_UTIL_LOGGING_LOGMANAGER_H_
+
+#include <map>
+#include <list>
+#include <string>
+#include <vector>
+
+#include <activemq/util/Properties.h>
+#include <activemq/concurrent/Mutex.h>
+
+namespace decaf{
+namespace util{
+namespace logging{
+
+    class Logger;
+    class PropertyChangeListener;
+
+    /**
+     * There is a single global LogManager object that is used to maintain
+     * a set of shared state about Loggers and log services.
+     *
+     * This LogManager object:
+     *
+     *   * Manages a hierarchical namespace of Logger objects. All named
+     *     Loggers are stored in this namespace.
+     *   * Manages a set of logging control properties. These are simple
+     *     key-value pairs that can be used by Handlers and other logging
+     *     objects to configure themselves.
+     *
+     * The global LogManager object can be retrieved using
+     * LogManager.getLogManager(). The LogManager object is created during
+     * class initialization and cannot subsequently be changed.
+     *
+     * ***TODO****
+     * By default, the LogManager reads its initial configuration from a
+     * properties file "lib/logging.properties" in the JRE directory. If
+     * you edit that property file you can change the default logging
+     * configuration for all uses of that JRE.
+     *
+     * In addition, the LogManager uses two optional system properties that
+     * allow more control over reading the initial configuration:
+     *
+     *    * "decaf.logger.config.class"
+     *    * "decaf.logger.config.file"
+     *
+     * These two properties may be set via the Preferences API, or as
+     * command line property definitions to the "java" command, or as
+     * system property definitions passed to JNI_CreateJavaVM.
+     *
+     * If the "java.util.logging.config.class" property is set, then the
+     * property value is treated as a class name. The given class will be
+     * loaded, an object will be instantiated, and that object's constructor
+     * is responsible for reading in the initial configuration. (That object
+     * may use other system properties to control its configuration.) The
+     * alternate configuration class can use readConfiguration(InputStream)
+     * to define properties in the LogManager.
+     *
+     * If "java.util.logging.config.class" property is not set, then the
+     * "java.util.logging.config.file" system property can be used to specify
+     * a properties file (in java.util.Properties format). The initial
+     * logging configuration will be read from this file.
+     *
+     * If neither of these properties is defined then, as described above,
+     * the LogManager will read its initial configuration from a properties
+     * file "lib/logging.properties" in the JRE directory.
+     *
+     * The properties for loggers and Handlers will have names starting with
+     * the dot-separated name for the handler or logger.
+     * ***TODO****
+     *
+     * The global logging properties may include:
+     *
+     *    * A property "handlers". This defines a whitespace separated
+     *      list of class names for handler classes to load and register as
+     *      handlers on the root Logger (the Logger named ""). Each class
+     *      name must be for a Handler class which has a default constructor.
+     *      Note that these Handlers may be created lazily, when they are
+     *      first used.
+     *    * A property "<logger>.handlers". This defines a whitespace or
+     *      comma separated list of class names for handlers classes to load
+     *      and register as handlers to the specified logger. Each class name
+     *      must be for a Handler class which has a default constructor. Note
+     *      that these Handlers may be created lazily, when they are first
+     *      used.
+     *    * A property "<logger>.useParentHandlers". This defines a boolean
+     *      value. By default every logger calls its parent in addition to
+     *      handling the logging message itself, this often result in
+     *      messages being handled by the root logger as well. When setting
+     *      this property to false a Handler needs to be configured for this
+     *      logger otherwise no logging messages are delivered.
+     *    * A property "config". This property is intended to allow arbitrary
+     *      configuration code to be run. The property defines a whitespace
+     *      separated list of class names. A new instance will be created for
+     *      each named class. The default constructor of each class may
+     *      execute arbitrary code to update the logging configuration, such
+     *      as setting logger levels, adding handlers, adding filters, etc.
+     *
+     * Loggers are organized into a naming hierarchy based on their dot
+     * separated names. Thus "a.b.c" is a child of "a.b", but "a.b1" and
+     * a.b2" are peers.
+     *
+     * All properties whose names end with ".level" are assumed to define
+     * log levels for Loggers. Thus "foo.level" defines a log level for
+     * the logger called "foo" and (recursively) for any of its children
+     * in the naming hierarchy. Log Levels are applied in the order they
+     * are defined in the properties file. Thus level settings for child
+     * nodes in the tree should come after settings for their parents. The
+     * property name ".level" can be used to set the level for the root of
+     * the tree.
+     *
+     * All methods on the LogManager object are multi-thread safe.
+     */
+    class LogManager {
+    private:
+
+        // Change listener on this class's Properties
+        std::list<PropertyChangeListener*> listeners;
+
+        // Properties of the Log Manager
+        util::Properties properties;
+
+    public:
+
+        virtual ~LogManager();
+
+        /**
+         * Sets the Properties this LogManager should use to configure
+         * its loggers.  Once set a properties change event is fired.
+         * @param properties Pointer to read the configuration from
+         */
+        virtual void setProperties( const util::Properties* properties );
+
+        /**
+         * Gets a reference to the Logging Properties used by this
+         * logger.
+         * @returns The Logger Properties Pointer
+         */
+        virtual const util::Properties& getProperties() const {
+            return properties;
+        }
+
+        /**
+         * Gets the value of a named property of this LogManager
+         * @param name of the Property to retrieve
+         * @return the value of the property
+         */
+        virtual std::string getProperty( const std::string& name ) {
+            return properties.getProperty( name );
+        }
+
+        /**
+         * Adds a change listener for LogManager Properties, adding the same
+         * instance of a change event listener does nothing.
+         * @param listener a PropertyChangeListener
+         */
+        virtual void addPropertyChangeListener(
+            PropertyChangeListener* listener );
+
+        /**
+         * Removes a properties change listener from the LogManager.
+         * @param listener a PropertyChangeListener
+         */
+        virtual void removePropertyChangeListener(
+            PropertyChangeListener* listener );
+
+        /**
+         * Retrieves or creates a new Logger using the name specified
+         * a new logger inherits the configuration of the logger's
+         * parent if there is no configuration data for the logger.
+         * @param name The name of the Logger.
+         */
+        virtual Logger* getLogger( const std::string& name );
+
+        /**
+         * Gets a list of known Logger Names from this Manager
+         * @param names STL Vector to hold string logger names
+         * @return names count of how many loggers were inserted
+         */
+        virtual int getLoggerNames( const std::vector<std::string>& names );
+
+    public:     // Static Singleton Methods.
+
+        /**
+         * Get the singleton instance
+         * @return Pointer to an instance of the Log Manager
+         */
+        static LogManager* getInstance();
+
+        /**
+         * Returns a Checked out instance of this Manager
+         */
+        static void returnInstance();
+
+        /**
+         * Forcefully Delete the Instance of this LogManager
+         * even if there are outstanding references.
+         */
+        static void destroy();
+
+    protected:
+
+        /**
+         * Constructor, hidden to protect against direct instantiation
+         */
+        LogManager() {}
+
+        /**
+         * Copy Constructo
+         * @param manager the Manager to copy
+         */
+        LogManager( const LogManager& manager );
+
+        /**
+         * Assignment operator
+         * @param manager the manager to assign from
+         */
+        void operator=( const LogManager& manager );
+
+    private:
+
+        // Static mutex to protect the singleton methods
+        static concurrent::Mutex mutex;
+
+        // Static pointer to the one and only instance.
+        static LogManager* instance;
+
+        // Static counter for number of outstanding references
+        static unsigned int refCount;
+
+    };
+
+}}}
+
+#endif /*_DECAF_UTIL_LOGGING_LOGMANAGER_H_*/

Added: activemq/activemq-cpp/trunk/src/decaf/util/logging/LogRecord.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/util/logging/LogRecord.h?view=auto&rev=543121
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/util/logging/LogRecord.h (added)
+++ activemq/activemq-cpp/trunk/src/decaf/util/logging/LogRecord.h Thu May 31 04:55:59 2007
@@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef _DECAF_UTIL_LOGGING_LOGRECORD_H_
+#define _DECAF_UTIL_LOGGING_LOGRECORD_H_
+
+#include <decaf/util/logging/LoggerCommon.h>
+
+#include <string>
+
+namespace decaf{
+namespace util{
+namespace logging{
+
+    class LogRecord
+    {
+    private:
+
+        // Level of this Record
+        Level level;
+
+        // Name of the source Logger
+        std::string loggerName;
+
+        // Name of the File that originated the Log
+        std::string sourceFile;
+
+        // Line in the source file where log occured
+        unsigned long sourceLine;
+
+        // The message to Log.
+        std::string message;
+
+        // The function Name where the log occured
+        std::string functionName;
+
+        // Time in Mills since UTC that this Record was logged
+        unsigned long timeStamp;
+
+        // Thread Id of the Thread that logged this Record
+        unsigned long threadId;
+
+    public:
+
+        LogRecord() {}
+        virtual ~LogRecord() {}
+
+        /**
+         * Get Level of this log record
+         * @return Level enumeration value.
+         */
+        Level getLevel() const {
+            return level;
+        };
+
+        /**
+         * Set the Level of this Log Record
+         * @param value Level Enumeration Value
+         */
+        void setLevel( Level value ) {
+            level = value;
+        };
+
+        /**
+         * Gets the Source Logger's Name
+         * @return the source loggers name
+         */
+        const std::string& getLoggerName() const {
+            return loggerName;
+        };
+
+        /**
+         * Sets the Source Logger's Name
+         * @param loggerName the source loggers name
+         */
+        void setLoggerName( const std::string& loggerName ) {
+            this->loggerName = loggerName;
+        };
+
+        /**
+         * Gets the Source Log File name
+         * @return the source loggers name
+         */
+        const std::string& getSourceFile() const {
+            return sourceFile;
+        };
+
+        /**
+         * Sets the Source Log File Name
+         * @param loggerName the source loggers name
+         */
+        void setSourceFile( const std::string& sourceFile ) {
+            this->sourceFile = sourceFile;
+        };
+
+        /**
+         * Gets the Source Log line number
+         * @return the source loggers line number
+         */
+        unsigned long getSourceLine() const {
+            return sourceLine;
+        };
+
+        /**
+         * Sets the Source Log line number
+         * @param sourceLine the source logger's line number
+         */
+        void setSourceLine( long sourceLine ) {
+            this->sourceLine = sourceLine;
+        };
+
+        /**
+         * Gets the Message to be Logged
+         * @return the source logger's message
+         */
+        const std::string& getMessage() const {
+            return message;
+        };
+
+        /**
+         * Sets the Message to be Logged
+         * @param message the source loggers message
+         */
+        void setMessage( const std::string& message ) {
+            this->message = message;
+        };
+
+        /**
+         * Gets the name of the function where this log was logged
+         * @return the source logger's message
+         */
+        const std::string& getSourceFunction() const {
+            return functionName;
+         };
+
+        /**
+         * Sets the name of the function where this log was logged
+         * @param functionName the source of the log
+         */
+        void setSourceFunction( const std::string& functionName ) {
+            this->functionName = functionName;
+        };
+
+        /**
+         * Gets the time in mills that this message was logged.
+         * @return UTC time in milliseconds
+         */
+        unsigned long getTimestamp() const { return timeStamp; };
+
+        /**
+         * Sets the time in mills that this message was logged.
+         * @param timeStamp UTC Time in Milliseconds.
+         */
+        void setTimestamp( long timeStamp ) {
+            this->timeStamp = timeStamp;
+        };
+
+        /**
+         * Gets the Thread Id where this Log was created
+         * @return the source loggers line number
+         */
+        unsigned long getTreadId() const {
+            return threadId;
+        };
+
+        /**
+         * Sets the Thread Id where this Log was created
+         * @param threadId the source logger's line number
+         */
+        void setTreadId( long threadId ) {
+            this->threadId = threadId;
+        };
+    };
+
+}}}
+
+#endif /*_DECAF_UTIL_LOGGING_LOGRECORD_H_*/

Added: activemq/activemq-cpp/trunk/src/decaf/util/logging/LogWriter.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/util/logging/LogWriter.cpp?view=auto&rev=543121
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/util/logging/LogWriter.cpp (added)
+++ activemq/activemq-cpp/trunk/src/decaf/util/logging/LogWriter.cpp Thu May 31 04:55:59 2007
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "LogWriter.h"
+
+#include <iostream>
+#include <activemq/concurrent/Thread.h>
+#include <activemq/concurrent/Concurrent.h>
+#include <activemq/concurrent/Mutex.h>
+#include <activemq/util/Config.h>
+
+using namespace std;
+using namespace activemq;
+using namespace activemq::concurrent;
+using namespace decaf::util::logging;
+
+////////////////////////////////////////////////////////////////////////////////
+concurrent::Mutex LogWriter::mutex;
+
+////////////////////////////////////////////////////////////////////////////////
+LogWriter::LogWriter(void)
+{
+}
+
+////////////////////////////////////////////////////////////////////////////////
+LogWriter::~LogWriter(void)
+{
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void LogWriter::log(const std::string& file AMQCPP_UNUSED,
+                    const int          line AMQCPP_UNUSED,
+                    const std::string& prefix,
+                    const std::string& message)
+{
+   synchronized(&mutex)
+   {
+      cout << prefix  << " "
+           << message << " - tid: " << Thread::getId() << endl;
+   }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void LogWriter::log(const std::string& message)
+{
+   synchronized(&mutex)
+   {
+      cout << message << " - tid: " << Thread::getId() << endl;
+   }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+LogWriter& LogWriter::getInstance(void)
+{
+    // This one instance
+    static LogWriter instance;
+
+    return instance;
+}
+

Added: activemq/activemq-cpp/trunk/src/decaf/util/logging/LogWriter.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/util/logging/LogWriter.h?view=auto&rev=543121
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/util/logging/LogWriter.h (added)
+++ activemq/activemq-cpp/trunk/src/decaf/util/logging/LogWriter.h Thu May 31 04:55:59 2007
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef _DECAF_UTIL_LOGGING_LOGWRITER_H_
+#define _DECAF_UTIL_LOGGING_LOGWRITER_H_
+
+#include <activemq/concurrent/Mutex.h>
+
+namespace decaf{
+namespace util{
+namespace logging{
+
+   class LogWriter
+   {
+   public:
+
+      LogWriter(void);
+      virtual ~LogWriter(void);
+
+      /**
+       * Writes a message to the output destination
+       * @param file
+       * @param line
+       * @param prefix
+       * @param message
+       */
+      virtual void log(const std::string& file,
+                       const int          line,
+                       const std::string& prefix,
+                       const std::string& message);
+
+      /**
+       * Writes a message to the output destination
+       * @param message
+       */
+      virtual void log(const std::string& message);
+
+   public:    // Static methods
+
+      /**
+       * Get the singleton instance
+       */
+      static LogWriter& getInstance();
+
+      /**
+       * Returns a Checked out instance of this Writer
+       */
+      static void returnInstance();
+
+      /**
+       * Forcefully Delete the Instance of this LogWriter
+       * even if there are outstanding references.
+       */
+      static void destroy();
+
+   private:
+
+      // Syncronization mutex
+      static concurrent::Mutex mutex;
+
+   };
+
+}}}
+
+#endif /*_DECAF_UTIL_LOGGING_LOGWRITER_H_*/

Added: activemq/activemq-cpp/trunk/src/decaf/util/logging/Logger.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/util/logging/Logger.cpp?view=auto&rev=543121
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/util/logging/Logger.cpp (added)
+++ activemq/activemq-cpp/trunk/src/decaf/util/logging/Logger.cpp Thu May 31 04:55:59 2007
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "Logger.h"
+
+#include <decaf/util/logging/Handler.h>
+#include <activemq/util/Config.h>
+#include <algorithm>
+
+using namespace std;
+using namespace activemq;
+using namespace activemq::exceptions;
+using namespace decaf::util::logging;
+
+////////////////////////////////////////////////////////////////////////////////
+Logger::Logger( const std::string& name AMQCPP_UNUSED,
+                Logger* parent AMQCPP_UNUSED ) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Logger::~Logger() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Logger::addHandler( Handler* handler ) throw ( IllegalArgumentException ) {
+
+    if( handler == NULL )
+    {
+        IllegalArgumentException(
+            __FILE__, __LINE__,
+            "Logger::addHandler - HAndler cannot be null");
+    }
+
+    if( find( handlers.begin(), handlers.end(), handler) != handlers.end() )
+    {
+        handlers.push_back( handler );
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Logger::removeHandler( Handler* handler ) {
+
+    list<Handler*>::iterator itr =
+        find( handlers.begin(), handlers.end(), handler );
+
+    if( itr != handlers.end() ) {
+
+        delete *itr;
+        handlers.erase(itr);
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Logger::setFilter( Filter* filter AMQCPP_UNUSED ){
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Logger::isLoggable( Level level AMQCPP_UNUSED ) const{
+    return false;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Logger::entry( const std::string& blockName AMQCPP_UNUSED,
+                    const std::string& file AMQCPP_UNUSED,
+                    const int line AMQCPP_UNUSED ) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Logger::exit(const std::string& blockName AMQCPP_UNUSED,
+                  const std::string& file AMQCPP_UNUSED,
+                  const int line AMQCPP_UNUSED) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Logger::debug( const std::string& file AMQCPP_UNUSED,
+                    const int line AMQCPP_UNUSED,
+                    const std::string fnctionName AMQCPP_UNUSED,
+                    const std::string& message AMQCPP_UNUSED ) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Logger::info( const std::string& file AMQCPP_UNUSED,
+                   const int line AMQCPP_UNUSED,
+                   const std::string fnctionName AMQCPP_UNUSED,
+                   const std::string& message AMQCPP_UNUSED ) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Logger::error( const std::string& file AMQCPP_UNUSED,
+                    const int line AMQCPP_UNUSED,
+                    const std::string fnctionName AMQCPP_UNUSED,
+                    const std::string& message AMQCPP_UNUSED ) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Logger::warn( const std::string& file AMQCPP_UNUSED,
+                   const int line AMQCPP_UNUSED,
+                   const std::string fnctionName AMQCPP_UNUSED,
+                   const std::string& message AMQCPP_UNUSED ) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Logger::fatal( const std::string& file AMQCPP_UNUSED,
+                    const int line AMQCPP_UNUSED,
+                    const std::string fnctionName AMQCPP_UNUSED,
+                    const std::string& message AMQCPP_UNUSED ) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Logger::log( Level level AMQCPP_UNUSED,
+                  const std::string& message AMQCPP_UNUSED ) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Logger::log( Level level AMQCPP_UNUSED,
+                  const std::string& file AMQCPP_UNUSED,
+                  const int line AMQCPP_UNUSED,
+                  const std::string& message AMQCPP_UNUSED,
+                  cms::CMSException& ex AMQCPP_UNUSED ) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Logger::log( Level level AMQCPP_UNUSED,
+                  const std::string& file AMQCPP_UNUSED,
+                  const int line AMQCPP_UNUSED,
+                  const std::string& message AMQCPP_UNUSED, ... ) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void Logger::log( LogRecord& record AMQCPP_UNUSED ) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Logger* Logger::getLogger( const std::string& name AMQCPP_UNUSED ) {
+    return NULL;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Logger* Logger::getAnonymousLogger() {
+    return NULL;
+}

Added: activemq/activemq-cpp/trunk/src/decaf/util/logging/Logger.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/util/logging/Logger.h?view=auto&rev=543121
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/util/logging/Logger.h (added)
+++ activemq/activemq-cpp/trunk/src/decaf/util/logging/Logger.h Thu May 31 04:55:59 2007
@@ -0,0 +1,405 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef _DECAF_UTIL_LOGGING_LOGGER_H_
+#define _DECAF_UTIL_LOGGING_LOGGER_H_
+
+#include <decaf/util/logging/LoggerCommon.h>
+#include <decaf/util/logging/LogRecord.h>
+#include <activemq/exceptions/IllegalArgumentException.h>
+
+#include <list>
+#include <string>
+#include <stdarg.h>
+
+namespace decaf{
+namespace util{
+namespace logging{
+
+    class Handler;
+    class Filter;
+
+    class Logger
+    {
+    private:
+
+        // The name of this Logger
+        std::string name;
+
+        // The Parent of this Logger
+        Logger* parent;
+
+        // list of Handlers owned by this logger
+        std::list<Handler*> handlers;
+
+        // Filter used by this Logger
+        Filter* filter;
+
+        // The Log Level of this Logger
+        Level level;
+
+        // Using Parent Handlers?
+        bool useParentHandlers;
+
+    public:
+
+        /**
+         * Creates a new instance of the Logger with the given name
+         * and assign it the given parent logger.
+         * <p>
+         * The logger will be initially configured with a null Level
+         * and with useParentHandlers true.
+         * @param name - A name for the logger. This should be a
+         * dot-separated name and should normally be based on the package
+         * name or class name of the subsystem, such as java.net or
+         * javax.swing. It may be null for anonymous Loggers.
+         * @param parent logger that is this one's parent
+         */
+        Logger( const std::string& name, Logger* parent );
+
+        virtual ~Logger();
+
+        /**
+         * Gets the name of this Logger
+         * @return logger name
+         */
+        virtual const std::string& getName(void) const {
+            return name;
+        }
+
+        /**
+         * Add a log Handler to receive logging messages.
+         * <p>
+         * By default, Loggers also send their output to their parent logger.
+         * Typically the root Logger is configured with a set of Handlers
+         * that essentially act as default handlers for all loggers.
+         *
+         * @param handler A Logging Handler
+         * #throws IllegalArgumentException
+         */
+        virtual void addHandler( Handler* handler )
+            throw ( exceptions::IllegalArgumentException );
+
+        /**
+         * Removes the specified Handler and destroys it
+         * <p>
+         * Returns silently if the given Handler is not found.
+         * @param handler The Handler to remove
+         */
+        virtual void removeHandler( Handler* handler );
+
+        /**
+         * Gets a vector containing all the handlers that this class
+         * has been assigned to use.
+         * @returns a list of handlers that are used by this logger
+         */
+        // virtual const std::list<Handler*>& getHandlers(void) const;
+
+        /**
+         * Set a filter to control output on this Logger.
+         * <p>
+         * After passing the initial "level" check, the Logger will call
+         * this Filter to check if a log record should really be published.
+         * <p>
+         * The caller releases ownership of this filter to this logger
+         * @param filter to use, can be null
+         */
+        virtual void setFilter( Filter* filter );
+
+        /**
+         * Gets the Filter object that this class is using.
+         * @return the Filter in use, can be null
+         */
+        virtual const Filter* getFilter() const {
+            return filter;
+        }
+
+        /**
+         * Get the log Level that has been specified for this Logger. The
+         * result may be the Null level, which means that this logger's
+         * effective level will be inherited from its parent.
+         * @return the level that is currently set
+         */
+        virtual Level getLevel() const {
+            return level;
+        }
+
+        /**
+         * Set the log level specifying which message levels will be logged
+         * by this logger. Message levels lower than this value will be
+         * discarded. The level value Level.OFF can be used to turn off
+         * logging.
+         * <p>
+         * If the new level is the Null Level, it means that this node
+         * should inherit its level from its nearest ancestor with a
+         * specific (non-null) level value.
+         * @param level new Level value
+         */
+        virtual void setLevel( Level level ) {
+            this->level = level;
+        }
+
+        /**
+         * Discover whether or not this logger is sending its output to
+         * its parent logger.
+         * @return true if using Parent Handlers
+         */
+        virtual bool getUseParentHandlers() const {
+            return useParentHandlers;
+        }
+
+        /**
+         * pecify whether or not this logger should send its output to it's
+         * parent Logger. This means that any LogRecords will also be
+         * written to the parent's Handlers, and potentially to its parent,
+         * recursively up the namespace.
+         * @param value True is output is to be writen to the parent
+         */
+        virtual void setUseParentHandlers( bool value ) {
+            this->useParentHandlers = value;
+        }
+
+        /**
+         * Logs an Block Enter message
+         * <p>
+         * This is a convenience method that is used to tag a block enter, a
+         * log record with the class name function name and the string
+         * Entering is logged at the DEBUG log level.
+         * @param blockName source block name
+         * @param file source file name
+         * @param line source line name
+         */
+        virtual void entry( const std::string& blockName,
+                            const std::string& file,
+                            const int line );
+
+        /**
+         * Logs an Block Exit message
+         * <p>
+         * This is a convenience method that is used to tag a block exit, a
+         * log record with the class name function name and the string
+         * Exiting is logged at the DEBUG log level.
+         * @param blockName source block name
+         * @param file source file name
+         * @param line source line name
+         */
+        virtual void exit( const std::string& blockName,
+                           const std::string& file,
+                           const int line );
+
+        /**
+         * Log a Debug Level Log
+         * <p>
+         * If the logger is currently enabled for the DEBUG message level
+         * then the given message is forwarded to all the registered output
+         * Handler objects.
+         * @param file the file name where the log was generated
+         * @param line the line number where the log was generated
+         * @param functionName name of the function that logged this
+         * @param message the message to log
+         */
+        virtual void debug( const std::string& file,
+                            const int line,
+                            const std::string functionName,
+                            const std::string& message );
+
+        /**
+         * Log a info Level Log
+         * <p>
+         * If the logger is currently enabled for the info message level
+         * then the given message is forwarded to all the registered output
+         * Handler objects.
+         *
+         * @param file the file name where the log was generated
+         * @param line the line number where the log was generated
+         * @param functionName name of the function that logged this
+         * @param message the message to log
+         */
+        virtual void info( const std::string& file,
+                           const int line,
+                           const std::string functionName,
+                           const std::string& message );
+
+        /**
+         * Log a warn Level Log
+         * <p>
+         * If the logger is currently enabled for the warn message level
+         * then the given message is forwarded to all the registered output
+         * Handler objects.
+         * @param file the file name where the log was generated
+         * @param line the line number where the log was generated
+         * @param functionName name of the function that logged this
+         * @param message the message to log
+         */
+        virtual void warn( const std::string& file,
+                           const int line,
+                           const std::string functionName,
+                           const std::string& message );
+
+        /**
+         * Log a error Level Log
+         * <p>
+         * If the logger is currently enabled for the error message level
+         * then the given message is forwarded to all the registered output
+         * Handler objects.
+         * @param file the file name where the log was generated
+         * @param line the line number where the log was generated
+         * @param fnctionName name of the function that logged this
+         * @param message the message to log
+         */
+        virtual void error( const std::string& file,
+                            const int line,
+                            const std::string fnctionName,
+                            const std::string& message );
+
+        /**
+         * Log a fatal Level Log
+         * <p>
+         * If the logger is currently enabled for the fatal message level
+         * then the given message is forwarded to all the registered output
+         * Handler objects.
+         * @param file the file name where the log was generated
+         * @param line the line number where the log was generated
+         * @param fnctionName name of the function that logged this
+         * @param message the message to log
+         */
+        virtual void fatal( const std::string& file,
+                            const int line,
+                            const std::string functionName,
+                            const std::string& message );
+
+        /**
+         * Log a Throw Message
+         * <p>
+         * If the logger is currently enabled for the Throwing message level
+         * then the given message is forwarded to all the registered output
+         * Handler objects.
+         * @param file the file name where the log was generated
+         * @param line the line number where the log was generated
+         * @param fnctionName name of the function that logged this
+         * @param message the message to log
+        virtual void throwing( const std::string& file,
+                               const int line,
+                               const std::string fnctionName,
+                               const std::string& message );
+         */
+
+        /**
+         * Check if a message of the given level would actually be logged
+         * by this logger. This check is based on the Loggers effective
+         * level, which may be inherited from its parent.
+         * @param level - a message logging level
+         * @returns true if the given message level is currently being logged.
+         */
+        virtual bool isLoggable( Level level ) const;
+
+        /**
+         * Log a LogRecord.
+         * All the other logging methods in this class call through this
+         * method to actually perform any logging. Subclasses can override
+         * this single method to capture all log activity.
+         * @param record - the LogRecord to be published
+         */
+        virtual void log( LogRecord& record );
+
+        /**
+         * Log a message, with no arguments.
+         * <p>
+         * If the logger is currently enabled for the given message level
+         * then the given message is forwarded to all the registered output
+         * Handler objects
+         * @param level the Level to log at
+         * @param message the message to log
+         */
+        virtual void log( Level level, const std::string& message );
+
+        /**
+         * Log a message, with the list of params that is formatted into
+         * the message string.
+         * <p>
+         * If the logger is currently enabled for the given message level
+         * then the given message is forwarded to all the registered output
+         * Handler objects
+         * @param level the Level to log at
+         * @param file the message to log
+         * @param line the line in the file
+         * @param variable length arguement to format the message string.
+         */
+        virtual void log( Level level,
+                          const std::string& file,
+                          const int line,
+                          const std::string& message, ... );
+
+        /**
+         * Log a message, with associated Throwable information.
+         * If the logger is currently enabled for the given message level
+         * then the given arguments are stored in a LogRecord which is
+         * forwarded to all registered output handlers.
+         * Note that the thrown argument is stored in the LogRecord thrown
+         * property, rather than the LogRecord parameters property. Thus is
+         * it processed specially by output Formatters and is not treated
+         * as a formatting parameter to the LogRecord message property.
+         * @param level the Level to log at
+         * @param file File that the message was logged in
+         * @param line the line number where the message was logged at.
+         * @param ex the Exception to log
+         */
+        virtual void log( Level level,
+                          const std::string& file,
+                          const int line,
+                          const std::string& message,
+                          cms::CMSException& ex );
+
+    public:
+
+        /**
+         * Creates an anonymous logger
+         * <p>
+         * The newly created Logger is not registered in the LogManager
+         * namespace. There will be no access checks on updates to the
+         * logger.
+         * Even although the new logger is anonymous, it is configured to
+         * have the root logger ("") as its parent. This means that by
+         * default it inherits its effective level and handlers from the
+         * root logger.
+         * <p>
+         * The caller is responsible for destroying the returned logger.
+         * @return Newly created anonymous logger
+         */
+        static Logger* getAnonymousLogger();
+
+        /**
+         * Find or create a logger for a named subsystem. If a logger has
+         * already been created with the given name it is returned.
+         * Otherwise a new logger is created.
+         * <p>
+         * If a new logger is created its log level will be configured based
+         * on the LogManager and it will configured to also send logging
+         * output to its parent loggers Handlers. It will be registered in
+         * the LogManager global namespace.
+         * @param name - A name for the logger. This should be a
+         * dot-separated name and should normally be based on the package
+         * name or class name of the subsystem, such as cms or
+         * activemq.core.ActiveMQConnection
+         * @return a suitable logger.
+         */
+        static Logger* getLogger( const std::string& name );
+
+    };
+
+}}}
+
+#endif /*_DECAF_UTIL_LOGGING_LOGGER_H_*/

Added: activemq/activemq-cpp/trunk/src/decaf/util/logging/LoggerCommon.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/util/logging/LoggerCommon.h?view=auto&rev=543121
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/util/logging/LoggerCommon.h (added)
+++ activemq/activemq-cpp/trunk/src/decaf/util/logging/LoggerCommon.h Thu May 31 04:55:59 2007
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef _DECAF_UTIL_LOGGING_LOGGERCOMMON_H_
+#define _DECAF_UTIL_LOGGING_LOGGERCOMMON_H_
+
+namespace decaf{
+namespace util{
+namespace logging{
+
+    /**
+     * Defines an enumeration for logging levels
+     */
+    enum Level
+    {
+        Off,
+        Null,
+        Markblock,
+        Debug,
+        Info,
+        Warn,
+        Error,
+        Fatal,
+        Throwing
+    };
+
+}}}
+
+#endif /*_DECAF_UTIL_LOGGING_LOGGERCOMMON_H_ */

Added: activemq/activemq-cpp/trunk/src/decaf/util/logging/LoggerDefines.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/util/logging/LoggerDefines.h?view=auto&rev=543121
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/util/logging/LoggerDefines.h (added)
+++ activemq/activemq-cpp/trunk/src/decaf/util/logging/LoggerDefines.h Thu May 31 04:55:59 2007
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef _DECAF_UTIL_LOGGING_LOGGERDEFINES_H_
+#define _DECAF_UTIL_LOGGING_LOGGERDEFINES_H_
+
+#include <decaf/util/logging/SimpleLogger.h>
+#include <sstream>
+
+#define LOGCMS_DECLARE(loggerName)                                  \
+   static activemq::logger::SimpleLogger loggerName;
+
+#define LOGCMS_INITIALIZE(loggerName, className, loggerFamily)      \
+   activemq::logger::SimpleLogger className::loggerName(loggerFamily);
+
+#define LOGCMS_DECLARE_LOCAL(loggerName)                            \
+   activemq::logger::Logger loggerName;
+
+#define LOGCMS_DEBUG(logger, message)                               \
+   logger.debug(__FILE__, __LINE__, message);
+
+#define LOGCMS_DEBUG_1(logger, message, value);                     \
+   {                                                                \
+      std::ostringstream ostream;                                   \
+      ostream << message << value;                                  \
+      logger.debug(__FILE__, __LINE__, ostream.str());              \
+   }
+
+#define LOGCMS_INFO(logger, message)                                \
+   logger.info(__FILE__, __LINE__, message);
+
+#define LOGCMS_ERROR(logger, message)                               \
+   logger.error(__FILE__, __LINE__, message);
+
+#define LOGCMS_WARN(logger, message)                                \
+   logger.warn(__FILE__, __LINE__, message);
+
+#define LOGCMS_FATAL(logger, message)                               \
+   logger.fatal(__FILE__, __LINE__, message);
+
+
+#endif

Added: activemq/activemq-cpp/trunk/src/decaf/util/logging/LoggerHierarchy.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/util/logging/LoggerHierarchy.cpp?view=auto&rev=543121
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/util/logging/LoggerHierarchy.cpp (added)
+++ activemq/activemq-cpp/trunk/src/decaf/util/logging/LoggerHierarchy.cpp Thu May 31 04:55:59 2007
@@ -0,0 +1,29 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include "LoggerHierarchy.h"
+
+using namespace decaf::util::logging;
+
+////////////////////////////////////////////////////////////////////////////////
+LoggerHierarchy::LoggerHierarchy(){
+}
+
+////////////////////////////////////////////////////////////////////////////////
+LoggerHierarchy::~LoggerHierarchy(){
+}
+

Added: activemq/activemq-cpp/trunk/src/decaf/util/logging/LoggerHierarchy.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/util/logging/LoggerHierarchy.h?view=auto&rev=543121
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/util/logging/LoggerHierarchy.h (added)
+++ activemq/activemq-cpp/trunk/src/decaf/util/logging/LoggerHierarchy.h Thu May 31 04:55:59 2007
@@ -0,0 +1,35 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#ifndef _DECAF_UTIL_LOGGING_LOGGERHIERARCHY_H_
+#define _DECAF_UTIL_LOGGING_LOGGERHIERARCHY_H_
+
+namespace decaf{
+namespace util{
+namespace logging{
+
+    class LoggerHierarchy
+    {
+    public:
+
+        LoggerHierarchy();
+        virtual ~LoggerHierarchy();
+
+    };
+
+}}}
+
+#endif /*_DECAF_UTIL_LOGGING_LOGGERHIERARCHY_H_*/

Added: activemq/activemq-cpp/trunk/src/decaf/util/logging/MarkBlockLogger.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/util/logging/MarkBlockLogger.h?view=auto&rev=543121
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/util/logging/MarkBlockLogger.h (added)
+++ activemq/activemq-cpp/trunk/src/decaf/util/logging/MarkBlockLogger.h Thu May 31 04:55:59 2007
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef _DECAF_UTIL_LOGGING_MARKBLOCKLOGGER_H_
+#define _DECAF_UTIL_LOGGING_MARKBLOCKLOGGER_H_
+
+#include <decaf/util/logging/Logger.h>
+
+namespace decaf{
+namespace util{
+namespace logging{
+
+    /**
+     * Defines a class that can be used to mark the entry and exit from
+     * scoped blocks.
+     * <p>
+     * Create an instance of this class at the start of a scoped block,
+     * passing it the logger to use and the name of the block.  The block
+     * entry and exit will be marked using the scope name, logger to the
+     * logger at the MARKBLOCK log level.
+     */
+    class MarkBlockLogger
+    {
+    private:
+
+        // Pointer to the Logger to use for Logging
+        Logger* logger;
+
+        // Block Name to Log
+        std::string blockName;
+
+    public:
+
+        /**
+         * Constructor - Marks Block entry
+         * @param logger Logger to use
+         * @param blockName Block name
+         */
+        MarkBlockLogger(Logger* logger, const std::string& blockName)
+        {
+            this->logger = logger;
+            this->blockName = blockName;
+
+            logger.mark(blockName + " - Entered");
+        }
+
+        virtual ~MarkBlockLogger(void)
+        {
+            logger->mark(blockName + " - Exited");
+        }
+
+    };
+
+}}}
+
+#endif /*_DECAF_UTIL_LOGGING_MARKBLOCKLOGGER_H_*/



Mime
View raw message