activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r906752 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main: ./ decaf/util/logging/
Date Fri, 05 Feb 2010 00:46:57 GMT
Author: tabish
Date: Fri Feb  5 00:46:56 2010
New Revision: 906752

URL: http://svn.apache.org/viewvc?rev=906752&view=rev
Log:
Finished some more of the implementation for the Logging package in Decaf.

Added:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ConsoleHandler.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ErrorManager.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ErrorManager.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Level.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Level.h   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogRecord.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/SimpleFormatter.cpp   (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/StreamHandler.cpp   (with props)
Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ConsoleHandler.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Formatter.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Handler.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogManager.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogManager.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogRecord.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Logger.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Logger.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LoggerCommon.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/SimpleFormatter.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/SimpleLogger.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/StreamHandler.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am?rev=906752&r1=906751&r2=906752&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am Fri Feb  5 00:46:56 2010
@@ -554,11 +554,17 @@
     decaf/util/concurrent/atomic/AtomicInteger.cpp \
     decaf/util/concurrent/locks/LockSupport.cpp \
     decaf/util/concurrent/locks/ReentrantLock.cpp \
+    decaf/util/logging/ConsoleHandler.cpp \
+    decaf/util/logging/ErrorManager.cpp \
+    decaf/util/logging/Level.cpp \
     decaf/util/logging/LogManager.cpp \
+    decaf/util/logging/LogRecord.cpp \
     decaf/util/logging/LogWriter.cpp \
     decaf/util/logging/Logger.cpp \
     decaf/util/logging/LoggerHierarchy.cpp \
-    decaf/util/logging/SimpleLogger.cpp
+    decaf/util/logging/SimpleFormatter.cpp \
+    decaf/util/logging/SimpleLogger.cpp \
+    decaf/util/logging/StreamHandler.cpp
 
 
 h_sources = \
@@ -1126,6 +1132,7 @@
     decaf/io/EOFException.h \
     decaf/io/FilterInputStream.h \
     decaf/io/FilterOutputStream.h \
+    decaf/io/Flushable.h \
     decaf/io/IOException.h \
     decaf/io/InputStream.h \
     decaf/io/InterruptedIOException.h \
@@ -1270,9 +1277,11 @@
     decaf/util/concurrent/locks/ReadWriteLock.h \
     decaf/util/concurrent/locks/ReentrantLock.h \
     decaf/util/logging/ConsoleHandler.h \
+    decaf/util/logging/ErrorManager.h \
     decaf/util/logging/Filter.h \
     decaf/util/logging/Formatter.h \
     decaf/util/logging/Handler.h \
+    decaf/util/logging/Level.h \
     decaf/util/logging/LogManager.h \
     decaf/util/logging/LogRecord.h \
     decaf/util/logging/LogWriter.h \

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ConsoleHandler.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ConsoleHandler.cpp?rev=906752&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ConsoleHandler.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ConsoleHandler.cpp Fri Feb  5 00:46:56 2010
@@ -0,0 +1,40 @@
+/*
+ * 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 "ConsoleHandler.h"
+
+#include <decaf/util/logging/Level.h>
+
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::util;
+using namespace decaf::util::logging;
+
+////////////////////////////////////////////////////////////////////////////////
+ConsoleHandler::ConsoleHandler() : StreamHandler( &stream, &formatter ) {
+
+    // Defaults level to Info
+    setLevel( Level::INFO );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ConsoleHandler::close() throw ( decaf::io::IOException )
+{
+    if( getOutputStream() ) {
+        getOutputStream()->flush();
+    }
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ConsoleHandler.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ConsoleHandler.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ConsoleHandler.h?rev=906752&r1=906751&r2=906752&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ConsoleHandler.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ConsoleHandler.h Fri Feb  5 00:46:56 2010
@@ -17,8 +17,11 @@
 #ifndef _DECAF_UTIL_LOGGING_CONSOLEHANDLER_H_
 #define _DECAF_UTIL_LOGGING_CONSOLEHANDLER_H_
 
+#include <decaf/util/Config.h>
 #include <decaf/util/logging/StreamHandler.h>
-#include <decaf/io/StandardErrorOutputStream.h>
+#include <decaf/util/logging/SimpleFormatter.h>
+#include <decaf/io/IOException.h>
+#include <decaf/internal/io/StandardErrorOutputStream.h>
 
 namespace decaf{
 namespace util{
@@ -39,23 +42,21 @@
      *  (defaults to no Filter).
      * ConsoleHandler.formatter specifies the name of a Formatter class to
      *  use (defaults to SimpleFormatter).
+     *
+     * @since 1.0
      */
     class DECAF_API ConsoleHandler : public StreamHandler {
     private:
 
         // The Standard Error Stream to log to
-        io::StandardErrorOutputStream stream;
+        internal::io::StandardErrorOutputStream stream;
 
         // The default Simple Formatter
         SimpleFormatter formatter;
 
     public:
 
-        ConsoleHandler() : StreamHandler( &stream, &formatter ) {
-
-            // Defaults level to Info
-            setLevel( Level.INFO );
-        }
+        ConsoleHandler();
 
         virtual ~ConsoleHandler() {}
 
@@ -66,15 +67,10 @@
          * but doesn't close.
          * @throw IOException
          */
-        virtual void close() throw ( IOException )
-        {
-            if( getOutputStream() ) {
-                getOutputStream->flush();
-            }
-        }
+        virtual void close() throw ( decaf::io::IOException );
 
     };
 
-}})
+}}}
 
 #endif /*_DECAF_UTIL_LOGGING_CONSOLEHANDLER_H_*/

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ErrorManager.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ErrorManager.cpp?rev=906752&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ErrorManager.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ErrorManager.cpp Fri Feb  5 00:46:56 2010
@@ -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.
+ */
+
+#include "ErrorManager.h"
+
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::util;
+using namespace decaf::util::logging;
+
+////////////////////////////////////////////////////////////////////////////////
+const int ErrorManager::GENERIC_FAILURE = 1;
+const int ErrorManager::WRITE_FAILURE = 2;
+const int ErrorManager::FLUSH_FAILURE = 3;
+const int ErrorManager::CLOSE_FAILURE = 4;
+const int ErrorManager::OPEN_FAILURE = 5;
+const int ErrorManager::FORMAT_FAILURE = 6;
+
+////////////////////////////////////////////////////////////////////////////////
+ErrorManager::~ErrorManager() {
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ErrorManager.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ErrorManager.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ErrorManager.h?rev=906752&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ErrorManager.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ErrorManager.h Fri Feb  5 00:46:56 2010
@@ -0,0 +1,93 @@
+/*
+ * 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_ERRORMANAGER_H_
+#define _DECAF_UTIL_LOGGING_ERRORMANAGER_H_
+
+#include <decaf/util/Config.h>
+#include <decaf/lang/Exception.h>
+
+#include <string>
+
+namespace decaf {
+namespace util {
+namespace logging {
+
+    /**
+     * ErrorManager objects can be attached to Handlers to process any error that occur on a
+     * Handler during Logging.
+     *
+     * When processing logging output, if a Handler encounters problems then rather than throwing
+     * an Exception back to the issuer of the logging call (who is unlikely to be interested) the
+     * Handler should call its associated ErrorManager.
+     *
+     * @since 1.0
+     */
+    class DECAF_API ErrorManager {
+    public:
+
+        /**
+         * GENERIC_FAILURE is used for failure that don't fit into one of the other categories.
+         */
+        static const int GENERIC_FAILURE;
+
+        /**
+         * WRITE_FAILURE is used when a write to an output stream fails.
+         */
+        static const int WRITE_FAILURE;
+
+        /**
+         * FLUSH_FAILURE is used when a flush to an output stream fails.
+         */
+        static const int FLUSH_FAILURE;
+
+        /**
+         * CLOSE_FAILURE is used when a close of an output stream fails.
+         */
+        static const int CLOSE_FAILURE;
+
+        /**
+         * OPEN_FAILURE is used when an open of an output stream fails.
+         */
+        static const int OPEN_FAILURE;
+
+        /**
+         * FORMAT_FAILURE is used when formatting fails for any reason.
+         */
+        static const int FORMAT_FAILURE;
+
+    public:
+
+        virtual ~ErrorManager();
+
+        /**
+         * The error method is called when a Handler failure occurs.
+         *
+         * This method may be overridden in subclasses. The default behavior in this base class is
+         * that the first call is reported to System.err, and subsequent calls are ignored.
+         *
+         * @param msg - a descriptive string (may be null)
+         * @param ex - an exception (may be null)
+         * @param code - an error code defined in ErrorManager
+         */
+        virtual void error( const std::string& message, decaf::lang::Exception& ex, int code ) = 0;
+
+    };
+
+}}}
+
+#endif /* _DECAF_UTIL_LOGGING_ERRORMANAGER_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ErrorManager.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Formatter.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Formatter.h?rev=906752&r1=906751&r2=906752&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Formatter.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Formatter.h Fri Feb  5 00:46:56 2010
@@ -17,6 +17,9 @@
 #ifndef _DECAF_UTIL_LOGGING_FORMATTER_H_
 #define _DECAF_UTIL_LOGGING_FORMATTER_H_
 
+#include <decaf/util/Config.h>
+#include <decaf/util/logging/Handler.h>
+
 namespace decaf{
 namespace util{
 namespace logging{

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Handler.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Handler.h?rev=906752&r1=906751&r2=906752&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Handler.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Handler.h Fri Feb  5 00:46:56 2010
@@ -18,7 +18,9 @@
 #define _DECAF_UTIL_LOGGING_HANDLER_H_
 
 #include <decaf/io/Closeable.h>
+#include <decaf/lang/Exception.h>
 #include <decaf/util/logging/LogRecord.h>
+#include <decaf/util/logging/Level.h>
 
 namespace decaf{
 namespace util{
@@ -26,6 +28,7 @@
 
     class Filter;
     class Formatter;
+    class ErrorManager;
 
     /**
      * A Handler object takes log messages from a Logger and exports them.
@@ -65,7 +68,7 @@
          * LogRecord.
          * @param record <code>LogRecord</code> to check
          */
-        virtual void isLoggable( const LogRecord& record ) = 0;
+        virtual bool isLoggable( const LogRecord& record ) const = 0;
 
         /**
          * Sets the Filter that this Handler uses to filter Log Records
@@ -75,7 +78,7 @@
          * discarded.
          * @param filter <code>Filter</code> derived instance
          */
-        virtual void setFilter( const Filter* filter ) = 0;
+        virtual void setFilter( Filter* filter ) = 0;
 
         /**
          * Gets the Filter that this Handler uses to filter Log Records
@@ -91,7 +94,7 @@
          * but to limit the messages that are sent to certain Handlers.
          * @param value Level enumeration value
          */
-        virtual void setLevel( Level value ) = 0;
+        virtual void setLevel( const Level& value ) = 0;
 
         /**
          * Get the log level specifying which message levels will be logged
@@ -107,7 +110,7 @@
          * Formatter will be remembered, but not used.
          * @param formatter <code>Filter</code> derived instance
          */
-        virtual void setFormatter( const Formatter* formatter ) = 0;
+        virtual void setFormatter( Formatter* formatter ) = 0;
 
         /**
          * Gets the <code>Formatter</code> used by this Handler
@@ -115,6 +118,22 @@
          */
         virtual const Formatter* getFormatter() = 0;
 
+        /**
+         * Sets the <code>Formatter</code> used by this Handler
+         * <p>
+         * The ErrorManager's "error" method will be invoked if any errors occur while
+         * using this Handler.
+         *
+         * @param errorManager <code>ErrorManager</code> derived instance
+         */
+        virtual void setErrorManager( ErrorManager* errorManager ) = 0;
+
+        /**
+         * Gets the <code>ErrorManager</code> used by this Handler.
+         * @returns <code>ErrorManager</code> derived pointer or NULL.
+         */
+        virtual const ErrorManager* getErrorManager() = 0;
+
    };
 
 }}}

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Level.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Level.cpp?rev=906752&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Level.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Level.cpp Fri Feb  5 00:46:56 2010
@@ -0,0 +1,124 @@
+/*
+ * 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 "Level.h"
+
+#include <decaf/lang/Integer.h>
+#include <decaf/lang/exceptions/NumberFormatException.h>
+#include <decaf/util/concurrent/Mutex.h>
+
+#include <vector>
+
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+using namespace decaf::util;
+using namespace decaf::util::concurrent;
+using namespace decaf::util::logging;
+
+////////////////////////////////////////////////////////////////////////////////
+namespace {
+
+    std::vector<Level> levels;
+    Mutex levelsLock;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+const Level Level::OFF( "OFF", Integer::MAX_VALUE );
+const Level Level::SEVERE( "SEVERE", 1000 );
+const Level Level::WARNING( "WARNING", 900 );
+const Level Level::INFO( "INFO", 800 );
+const Level Level::DEBUG( "DEBUG", 700 );
+const Level Level::CONFIG( "CONFIG", 600 );
+const Level Level::FINE( "FINE", 500 );
+const Level Level::FINER( "FINER", 400 );
+const Level Level::FINEST( "FINEST", 300 );
+const Level Level::ALL( "ALL", Integer::MIN_VALUE );
+
+////////////////////////////////////////////////////////////////////////////////
+Level::Level( const std::string& name, int value ) : name( name ), value( value ) {
+    levels.push_back( *this );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Level::~Level() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Level::compareTo( const Level& value ) const {
+    return this->value < value.value ? -1 : this->value > value.value ? 1 : 0;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Level::equals( const Level& value ) const {
+    return this->value == value.value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Level::operator==( const Level& value ) const {
+    return this->value == value.value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Level::operator<( const Level& value ) const {
+    return this->value < value.value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Level Level::parse( const std::string& name )
+    throw( decaf::lang::exceptions::IllegalArgumentException ) {
+
+    bool isNameAnInt;
+    int nameAsInt;
+
+    try {
+        nameAsInt = Integer::parseInt( name );
+        isNameAnInt = true;
+    } catch( NumberFormatException& e ) {
+        nameAsInt = 0;
+        isNameAnInt = false;
+    }
+
+    synchronized( &levelsLock ) {
+
+        std::vector<Level>::const_iterator level = levels.begin();
+
+        for( ; level != levels.end(); ++level ) {
+            if( name == level->getName() ) {
+                return *level;
+            }
+        }
+
+        // If the name was an int then we loop again to check the int value
+        // against each level's value.
+        if( isNameAnInt ) {
+
+            for( level = levels.begin(); level != levels.end(); ++ level ) {
+                if( nameAsInt == level->intValue()) {
+                    return *level;
+                }
+            }
+        }
+    }
+
+    if( !isNameAnInt ) {
+        throw IllegalArgumentException(
+            __FILE__, __LINE__, "Could not find match for Level Name: %s", name.c_str() );
+    }
+
+    return Level( name, nameAsInt );
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Level.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Level.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Level.h?rev=906752&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Level.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Level.h Fri Feb  5 00:46:56 2010
@@ -0,0 +1,226 @@
+/*
+ * 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_LEVEL_H_
+#define _DECAF_UTIL_LOGGING_LEVEL_H_
+
+#include <decaf/util/Config.h>
+
+#include <decaf/lang/Comparable.h>
+#include <decaf/lang/exceptions/IllegalArgumentException.h>
+
+namespace decaf {
+namespace util {
+namespace logging {
+
+    /**
+     * The Level class defines a set of standard logging levels that can be used to control logging
+     * output. The logging Level objects are ordered and are specified by ordered integers.
+     * Enabling logging at a given level also enables logging at all higher levels.
+     *
+     * Clients should normally use the predefined Level constants such as Level.SEVERE.
+     *
+     * The levels in descending order are:
+     *
+     *   * SEVERE (highest value)
+     *   * WARNING
+     *   * INFO
+     *   * CONFIG
+     *   * FINE
+     *   * FINER
+     *   * FINEST (lowest value)
+     *
+     * In addition there is a level OFF that can be used to turn off logging, and a level ALL that
+     * can be used to enable logging of all messages.
+     *
+     * It is possible for third parties to define additional logging levels by subclassing Level.
+     * In such cases subclasses should take care to chose unique integer level values.
+     *
+     * @since 1.0
+     */
+    class DECAF_API Level : public decaf::lang::Comparable<Level> {
+    private:
+
+        std::string name;
+        int value;
+
+    public:
+
+        /**
+         * OFF is a special level that can be used to turn off logging. This level is initialized
+         * to Integer::MAX_VALUE
+         */
+        static const Level OFF;
+
+        /**
+         * SEVERE is a message level indicating a serious failure.
+         *
+         * In general SEVERE messages should describe events that are of considerable importance
+         * and which will prevent normal program execution. They should be reasonably intelligible
+         * to end users and to system administrators. This level is initialized to 1000.
+         */
+        static const Level SEVERE;
+
+        /**
+         * WARNING is a message level indicating a potential problem.
+         *
+         * In general WARNING messages should describe events that will be of interest to end users
+         * or system managers, or which indicate potential problems. This level is initialized to 900.
+         */
+        static const Level WARNING;
+
+        /**
+         * INFO is a message level for informational messages.
+         *
+         * Typically INFO messages will be written to the console or its equivalent. So the INFO
+         * level should only be used for reasonably significant messages that will make sense to end
+         * users and system admins. This level is initialized to 800.
+         */
+        static const Level INFO;
+
+        /**
+         * DEBUG is a level for more verbose informative messages.
+         *
+         * DEBUG messages are intended to provide a more detailed message intended for use by
+         * developers in tracking the behavior of a client.  DEBUG messages typically contain more
+         * implementation specific information that might not be significant to end users or system
+         * admins.  This level is initialized to 700.
+         */
+        static const Level DEBUG;
+
+        /**
+         * CONFIG is a message level for static configuration messages.
+         *
+         * CONFIG messages are intended to provide a variety of static configuration information, to
+         * assist in debugging problems that may be associated with particular configurations. For
+         * example, CONFIG message might include the CPU type, the System properties, etc. This level
+         * is initialized to 600.
+         */
+        static const Level CONFIG;
+
+        /**
+         * FINE is a message level providing tracing information.
+         *
+         * All of FINE, FINER, and FINEST are intended for relatively detailed tracing. The exact
+         * meaning of the three levels will vary between subsystems, but in general, FINEST should
+         * be used for the most detailed output, FINER for somewhat less detailed output, and FINE
+         * for the lowest volume (and most important) messages.
+         *
+         * In general the FINE level should be used for information that will be broadly interesting
+         * to developers who do not have a specialized interest in the specific subsystem.
+         *
+         * FINE messages might include things like minor (recoverable) failures. Issues indicating
+         * potential performance problems are also worth logging as FINE. This level is initialized
+         * to 500.
+         */
+        static const Level FINE;
+
+        /**
+         * FINER indicates a fairly detailed tracing message. By default logging calls for entering,
+         * returning, or throwing an exception are traced at this level. This level is initialized
+         * to 400.
+         */
+        static const Level FINER;
+
+        /**
+         * FINEST indicates a highly detailed tracing message. This level is initialized to 300.
+         */
+        static const Level FINEST;
+
+        /**
+         * ALL indicates that all messages should be logged. This level is initialized
+         * to Integer::MIN_VALUE.
+         */
+        static const Level ALL;
+
+    protected:
+
+        /**
+         * Create a named Level with a given integer value.
+         *
+         * @param name
+         *      Name of the level, e.g. SEVERE
+         * @param value
+         *      Unique integer value of this level, e.g. 100
+         */
+        Level( const std::string& name, int value );
+
+    public:
+
+        virtual ~Level();
+
+        /**
+         * @return the integer value of this level instance.
+         */
+        int intValue() const {
+            return this->value;
+        }
+
+        /**
+         * @return the name of this Level instance.
+         */
+        std::string getName() const {
+            return this->name;
+        }
+
+        /**
+         * @return the string value of this Level, e.g. "SEVERE".
+         */
+        std::string toString() const {
+            return this->name;
+        }
+
+    public:  // Comparable
+
+        virtual int compareTo( const Level& value ) const;
+
+        virtual bool equals( const Level& value ) const;
+
+        virtual bool operator==( const Level& value ) const;
+
+        virtual bool operator<( const Level& value ) const;
+
+    public:
+
+        /**
+         * Parse a level name string into a Level.
+         *
+         * The argument string may consist of either a level name or an integer value.
+         *
+         * For example:
+         *
+         *  * "SEVERE"
+         *  * "1000"
+         *
+         * @param name - The name or int value of the desired Level
+         *
+         * @return the parsed Level value, passing in a level name that is an int value that
+         *         is not one of the known Level values will result in a new Level that has
+         *         been initialized with that int value and name as the string form of the int.
+         *
+         * @throws IllegalArgumentException if the value is not valid, validity means that the
+         *         string is either a valid int (between Integer::MIN_VALUE and Integer::MAX_VALUE
+         *         or is one of the known level names.
+         */
+        static Level parse( const std::string& name )
+            throw( decaf::lang::exceptions::IllegalArgumentException );
+
+    };
+
+}}}
+
+#endif /* _DECAF_UTIL_LOGGING_LEVEL_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Level.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogManager.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogManager.cpp?rev=906752&r1=906751&r2=906752&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogManager.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogManager.cpp Fri Feb  5 00:46:56 2010
@@ -16,26 +16,55 @@
 */
 #include "LogManager.h"
 
+#include <decaf/lang/exceptions/RuntimeException.h>
+#include <decaf/util/StlMap.h>
 #include <decaf/util/logging/PropertiesChangeListener.h>
+#include <decaf/util/logging/Logger.h>
 #include <decaf/util/concurrent/Concurrent.h>
 #include <decaf/util/Config.h>
 
+#include <string>
 #include <algorithm>
 
 using namespace std;
 using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
 using namespace decaf::util;
 using namespace decaf::util::logging;
 
 ////////////////////////////////////////////////////////////////////////////////
-LogManager::~LogManager()
-{
+namespace decaf{
+namespace util{
+namespace logging{
+
+    class LogManagerInternals {
+    public:
+
+        StlMap<string, Logger*> loggers;
+    };
+
+}}}
+
+////////////////////////////////////////////////////////////////////////////////
+namespace {
+
+    LogManager* theManager = NULL;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+LogManager::LogManager() {
+
+    this->internal.reset( new LogManagerInternals() );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+LogManager::~LogManager() {
     // TODO - Delete all the loggers.
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void LogManager::setProperties( const Properties& properties )
-{
+void LogManager::setProperties( const Properties& properties ) {
     // Copy the properties
     this->properties = properties;
 
@@ -70,15 +99,26 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-LogManager* LogManager::getInstance() {
-    return NULL;
+LogManager& LogManager::getLogManager() {
+
+    if( theManager == NULL ) {
+        throw RuntimeException(
+            __FILE__, __LINE__, "The Logging Subsystem is not initialized." );
+    }
+
+    return *theManager;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void LogManager::returnInstance() {
+void LogManager::initialize() {
+
+    // Initialize the global instance.
+    theManager = new LogManager;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void LogManager::destroy()
-{
+void LogManager::shutdown() {
+
+    // Destroy the global LogManager
+    delete theManager;
 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogManager.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogManager.h?rev=906752&r1=906751&r2=906752&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogManager.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogManager.h Fri Feb  5 00:46:56 2010
@@ -22,17 +22,24 @@
 #include <string>
 #include <vector>
 
+#include <decaf/lang/Pointer.h>
 #include <decaf/util/Properties.h>
 #include <decaf/util/concurrent/Mutex.h>
 #include <decaf/util/Config.h>
 
 namespace decaf{
+namespace lang{
+    class Runtime;
+}
 namespace util{
 namespace logging{
 
     class Logger;
+    class LogManagerInternals;
     class PropertyChangeListener;
 
+    using decaf::lang::Pointer;
+
     /**
      * There is a single global LogManager object that is used to maintain
      * a set of shared state about Loggers and log services.
@@ -127,6 +134,8 @@
      * the tree.
      *
      * All methods on the LogManager object are multi-thread safe.
+     *
+     * @since 1.0
      */
     class DECAF_API LogManager {
     private:
@@ -137,6 +146,9 @@
         // Properties of the Log Manager
         util::Properties properties;
 
+        // Data structure for LogManager Internal data.
+        Pointer<LogManagerInternals> internal;
+
     public:
 
         virtual ~LogManager();
@@ -199,28 +211,29 @@
     public:     // Static Singleton Methods.
 
         /**
-         * Get the singleton instance
-         * @return Pointer to an instance of the Log Manager
+         * Get the global {@code LogManager} instance.
+         * @return A reference to the global LogManager instaince.
          */
-        static LogManager* getInstance();
+        static LogManager& getLogManager();
+
+    private:
 
         /**
-         * Returns a Checked out instance of this Manager
+         * Initialize the Logging subsystem.
          */
-        static void returnInstance();
+        static void initialize();
 
         /**
-         * Forcefully Delete the Instance of this LogManager
-         * even if there are outstanding references.
+         * Shutdown the Logging subsystem.
          */
-        static void destroy();
+        static void shutdown();
 
     protected:
 
         /**
          * Constructor, hidden to protect against direct instantiation
          */
-        LogManager() {}
+        LogManager();
 
         /**
          * Copy Constructo
@@ -234,6 +247,10 @@
          */
         void operator=( const LogManager& manager );
 
+    private:
+
+        friend class decaf::lang::Runtime;
+
     };
 
 }}}

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogRecord.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogRecord.cpp?rev=906752&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogRecord.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogRecord.cpp Fri Feb  5 00:46:56 2010
@@ -0,0 +1,30 @@
+/*
+* 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 "LogRecord.h"
+
+using namespace std;
+using namespace decaf;
+using namespace decaf::util;
+using namespace decaf::util::logging;
+
+////////////////////////////////////////////////////////////////////////////////
+LogRecord::LogRecord() : level( Level::OFF ){
+}
+
+////////////////////////////////////////////////////////////////////////////////
+LogRecord::~LogRecord() {
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogRecord.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogRecord.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogRecord.h?rev=906752&r1=906751&r2=906752&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogRecord.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LogRecord.h Fri Feb  5 00:46:56 2010
@@ -17,15 +17,27 @@
 #ifndef _DECAF_UTIL_LOGGING_LOGRECORD_H_
 #define _DECAF_UTIL_LOGGING_LOGRECORD_H_
 
+#include <decaf/lang/Throwable.h>
 #include <decaf/util/logging/LoggerCommon.h>
+#include <decaf/util/logging/Level.h>
 #include <decaf/util/Config.h>
 
+#include <memory>
 #include <string>
 
 namespace decaf{
 namespace util{
 namespace logging{
 
+    /**
+     * LogRecord objects are used to pass logging requests between the logging framework and
+     * individual log Handlers.
+     *
+     * When a LogRecord is passed into the logging framework it logically belongs to the framework
+     * and should no longer be used or updated by the client application.
+     *
+     * @since 1.0
+     */
     class DECAF_API LogRecord {
     private:
 
@@ -39,7 +51,7 @@
         std::string sourceFile;
 
         // Line in the source file where log occurred
-        unsigned long sourceLine;
+        unsigned int sourceLine;
 
         // The message to Log.
         std::string message;
@@ -48,15 +60,19 @@
         std::string functionName;
 
         // Time in Mills since UTC that this Record was logged
-        unsigned long timeStamp;
+        long long timeStamp;
 
         // Thread Id of the Thread that logged this Record
-        unsigned long threadId;
+        long long threadId;
+
+        // A Throwable that is associated with this record
+        std::auto_ptr<decaf::lang::Throwable> thrown;
 
     public:
 
-        LogRecord() {}
-        virtual ~LogRecord() {}
+        LogRecord();
+
+        virtual ~LogRecord();
 
         /**
          * Get Level of this log record
@@ -110,7 +126,7 @@
          * Gets the Source Log line number
          * @return the source loggers line number
          */
-        unsigned long getSourceLine() const {
+        unsigned int getSourceLine() const {
             return sourceLine;
         };
 
@@ -118,7 +134,7 @@
          * Sets the Source Log line number
          * @param sourceLine the source logger's line number
          */
-        void setSourceLine( long sourceLine ) {
+        void setSourceLine( unsigned int sourceLine ) {
             this->sourceLine = sourceLine;
         };
 
@@ -158,13 +174,13 @@
          * Gets the time in mills that this message was logged.
          * @return UTC time in milliseconds
          */
-        unsigned long getTimestamp() const { return timeStamp; };
+        long 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 ) {
+        void setTimestamp( long long timeStamp ) {
             this->timeStamp = timeStamp;
         };
 
@@ -172,7 +188,7 @@
          * Gets the Thread Id where this Log was created
          * @return the source loggers line number
          */
-        unsigned long getTreadId() const {
+        long long getTreadId() const {
             return threadId;
         };
 
@@ -180,9 +196,30 @@
          * Sets the Thread Id where this Log was created
          * @param threadId the source logger's line number
          */
-        void setTreadId( long threadId ) {
+        void setTreadId( long long threadId ) {
             this->threadId = threadId;
         };
+
+        /**
+         * Gets any Throwable associated with this LogRecord
+         * @return point to a Throwable instance or Null.
+         */
+        decaf::lang::Throwable* getThrown() const {
+            return this->thrown.get();
+        }
+
+        /**
+         * Sets the Throwable associated with this LogRecord, the pointer becomes
+         * the property of this instance of the LogRecord and will be deleted when
+         * the record is destroyed.
+         *
+         * @param thrown
+         *      A pointer to a Throwable that will be associated with this record.
+         */
+        void setThrown( decaf::lang::Throwable* thrown ) {
+            this->thrown.reset( thrown );
+        }
+
     };
 
 }}}

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Logger.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Logger.cpp?rev=906752&r1=906751&r2=906752&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Logger.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Logger.cpp Fri Feb  5 00:46:56 2010
@@ -69,7 +69,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-bool Logger::isLoggable( Level level DECAF_UNUSED ) const{
+bool Logger::isLoggable( Levels level DECAF_UNUSED ) const{
     return false;
 }
 
@@ -121,12 +121,12 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void Logger::log( Level level DECAF_UNUSED,
+void Logger::log( Levels level DECAF_UNUSED,
                   const std::string& message DECAF_UNUSED ) {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void Logger::log( Level level DECAF_UNUSED,
+void Logger::log( Levels level DECAF_UNUSED,
                   const std::string& file DECAF_UNUSED,
                   const int line DECAF_UNUSED,
                   const std::string& message DECAF_UNUSED,
@@ -134,7 +134,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void Logger::log( Level level DECAF_UNUSED,
+void Logger::log( Levels level DECAF_UNUSED,
                   const std::string& file DECAF_UNUSED,
                   const int line DECAF_UNUSED,
                   const std::string& message DECAF_UNUSED, ... ) {

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Logger.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Logger.h?rev=906752&r1=906751&r2=906752&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Logger.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/Logger.h Fri Feb  5 00:46:56 2010
@@ -49,7 +49,7 @@
         Filter* filter;
 
         // The Log Level of this Logger
-        Level level;
+        Levels level;
 
         // Using Parent Handlers?
         bool useParentHandlers;
@@ -133,7 +133,7 @@
          * effective level will be inherited from its parent.
          * @return the level that is currently set
          */
-        virtual Level getLevel() const {
+        virtual Levels getLevel() const {
             return level;
         }
 
@@ -148,7 +148,7 @@
          * specific (non-null) level value.
          * @param level new Level value
          */
-        virtual void setLevel( Level level ) {
+        virtual void setLevel( Levels level ) {
             this->level = level;
         }
 
@@ -304,7 +304,7 @@
          * @param level - a message logging level
          * @returns true if the given message level is currently being logged.
          */
-        virtual bool isLoggable( Level level ) const;
+        virtual bool isLoggable( Levels level ) const;
 
         /**
          * Log a LogRecord.
@@ -324,7 +324,7 @@
          * @param level the Level to log at
          * @param message the message to log
          */
-        virtual void log( Level level, const std::string& message );
+        virtual void log( Levels level, const std::string& message );
 
         /**
          * Log a message, with the list of params that is formatted into
@@ -338,7 +338,7 @@
          * @param line the line in the file
          * @param ... variable length argument to format the message string.
          */
-        virtual void log( Level level,
+        virtual void log( Levels levels,
                           const std::string& file,
                           const int line,
                           const std::string& message, ... );
@@ -358,7 +358,7 @@
          * @param message the message to log.
          * @param ex the Exception to log
          */
-        virtual void log( Level level,
+        virtual void log( Levels level,
                           const std::string& file,
                           const int line,
                           const std::string& message,

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LoggerCommon.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LoggerCommon.h?rev=906752&r1=906751&r2=906752&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LoggerCommon.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/LoggerCommon.h Fri Feb  5 00:46:56 2010
@@ -24,7 +24,7 @@
     /**
      * Defines an enumeration for logging levels
      */
-    enum Level
+    enum Levels
     {
         Off,
         Null,

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/SimpleFormatter.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/SimpleFormatter.cpp?rev=906752&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/SimpleFormatter.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/SimpleFormatter.cpp Fri Feb  5 00:46:56 2010
@@ -0,0 +1,53 @@
+/*
+ * 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 "SimpleFormatter.h"
+
+#include <decaf/util/logging/Level.h>
+
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::util;
+using namespace decaf::util::logging;
+
+////////////////////////////////////////////////////////////////////////////////
+SimpleFormatter::SimpleFormatter() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+SimpleFormatter::~SimpleFormatter() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string SimpleFormatter::format( const LogRecord& record DECAF_UNUSED ) const {
+    return "";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string SimpleFormatter::formatMessage( const LogRecord& record ) const{
+    return record.getMessage();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string SimpleFormatter::getHead( const Handler* handler DECAF_UNUSED ) {
+    return "";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string SimpleFormatter::getTail( const Handler* handler DECAF_UNUSED ) {
+    return "";
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/SimpleFormatter.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/SimpleFormatter.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/SimpleFormatter.h?rev=906752&r1=906751&r2=906752&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/SimpleFormatter.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/SimpleFormatter.h Fri Feb  5 00:46:56 2010
@@ -17,7 +17,10 @@
 #ifndef _DECAF_UTIL_LOGGING_SIMPLEFORMATTER_H_
 #define _DECAF_UTIL_LOGGING_SIMPLEFORMATTER_H_
 
-#include <decaf/util/logging/formatter.h>
+#include <decaf/util/Config.h>
+#include <decaf/util/logging/Formatter.h>
+
+#include <string>
 
 namespace decaf{
 namespace util{
@@ -30,24 +33,20 @@
     class DECAF_API SimpleFormatter : public Formatter {
     public:
 
-        SimpleFormatter() {}
-        virtual ~SimpleFormatter() {}
+        SimpleFormatter();
+        virtual ~SimpleFormatter();
 
         /**
          * Format the given log record and return the formatted string.
          * @param record The Log Record to Format
          */
-        virtual std::string format( const LogRecord& record ) const {
-            return "";
-        }
+        virtual std::string format( const LogRecord& record ) const;
 
         /**
          * Format the message string from a log record.
          * @param record The Log Record to Format
          */
-         virtual std::string formatMessage( const LogRecord& record ) const{
-            return record.getMessage();
-        }
+         virtual std::string formatMessage( const LogRecord& record ) const;
 
         /**
          * Return the header string for a set of formatted records.  In the
@@ -55,9 +54,7 @@
          * @param handler the target handler, can be null
          * @return empty string
          */
-        virtual std::string getHead( const Handler* handler ) {
-            return "";
-        }
+        virtual std::string getHead( const Handler* handler );
 
         /**
          * Return the tail string for a set of formatted records.  In the
@@ -65,9 +62,7 @@
          * @param handler the target handler, can be null
          * @return empty string
          */
-        virtual std::string getTail( const Handler* handler ) {
-            return "";
-        }
+        virtual std::string getTail( const Handler* handler );
 
     };
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/SimpleLogger.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/SimpleLogger.cpp?rev=906752&r1=906751&r2=906752&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/SimpleLogger.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/SimpleLogger.cpp Fri Feb  5 00:46:56 2010
@@ -25,14 +25,13 @@
 using namespace decaf::util::logging;
 
 ////////////////////////////////////////////////////////////////////////////////
-SimpleLogger::SimpleLogger( const std::string& name )
-{
+SimpleLogger::SimpleLogger( const std::string& name ) {
     this->name = name;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-SimpleLogger::~SimpleLogger()
-{}
+SimpleLogger::~SimpleLogger() {
+}
 
 ////////////////////////////////////////////////////////////////////////////////
 void SimpleLogger::mark( const std::string& message ) {

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/StreamHandler.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/StreamHandler.cpp?rev=906752&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/StreamHandler.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/StreamHandler.cpp Fri Feb  5 00:46:56 2010
@@ -0,0 +1,107 @@
+/*
+ * 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 "StreamHandler.h"
+
+#include <decaf/util/logging/Level.h>
+#include <decaf/io/OutputStream.h>
+
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::io;
+using namespace decaf::util;
+using namespace decaf::util::logging;
+
+////////////////////////////////////////////////////////////////////////////////
+StreamHandler::StreamHandler() : level( Level::SEVERE ) {
+
+    this->stream = NULL;
+    this->formatter = NULL;
+    this->filter = NULL;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+StreamHandler::StreamHandler( OutputStream* stream, Formatter* formatter ) : level( Level::SEVERE ) {
+
+    this->stream = stream;
+    this->formatter = formatter;
+    this->filter = NULL;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+StreamHandler::~StreamHandler() {
+
+    try {
+        this->close();
+    }
+    DECAF_CATCH_NOTHROW( lang::Exception)
+    DECAF_CATCHALL_NOTHROW()
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StreamHandler::close() throw ( decaf::io::IOException ) {
+    if( stream ) {
+        stream->flush();
+        stream->close();
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StreamHandler::flush() {
+    if( stream ) {
+        stream->flush();
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void StreamHandler::publish( const LogRecord& record ) {
+
+    try {
+
+        if( !stream ) {
+            throw lang::exceptions::NullPointerException(
+                __FILE__, __LINE__,
+                "StreamHandler::publish - Stream not set.");
+        }
+
+        // Check if we should log this record
+        if( isLoggable( record ) ) {
+
+            std::string log = formatter->format( record );
+
+            synchronized( stream ) {
+                // Write the data to the stream
+                stream->write( (const unsigned char*)log.c_str(), 0, log.length() );
+            }
+        }
+    }
+    DECAF_CATCH_RETHROW( lang::Exception )
+    DECAF_CATCHALL_THROW( lang::Exception )
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool StreamHandler::isLoggable( const LogRecord& record ) const {
+
+    if( filter ) {
+        // Allow for some filtering to occur
+        return filter->isLoggable( record );
+    }
+
+    // By default we want everything that is greater than our
+    // equal to the set level of this Handler.
+    return record.getLevel().compareTo( this->level ) >= 0;
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/StreamHandler.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/StreamHandler.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/StreamHandler.h?rev=906752&r1=906751&r2=906752&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/StreamHandler.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/StreamHandler.h Fri Feb  5 00:46:56 2010
@@ -21,13 +21,16 @@
 #include <decaf/util/logging/Handler.h>
 #include <decaf/util/logging/Formatter.h>
 #include <decaf/util/logging/Filter.h>
-#include <decaf/io/OutputStream.h>
+#include <decaf/util/logging/ErrorManager.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
 #include <decaf/lang/exceptions/InvalidStateException.h>
 #include <decaf/util/concurrent/Concurrent.h>
 #include <decaf/util/Config.h>
 
 namespace decaf{
+namespace io{
+    class OutputStream;
+}
 namespace util{
 namespace logging{
 
@@ -35,7 +38,7 @@
     private:
 
         // OutputStream to write to
-        io::OutputStream* stream;
+        decaf::io::OutputStream* stream;
 
         // Formats this Handlers output
         Formatter* formatter;
@@ -43,37 +46,25 @@
         // Filter object for Log Filtering
         Filter* filter;
 
+        // ErrorManager instance for this Handler
+        ErrorManager* errorManager;
+
+        // Level at which that this Handler will start logging.
+        Level level;
+
     public:
 
         /**
          * Create a StreamHandler, with no current output stream.
          */
-        StreamHandler() {
-            this->stream = NULL;
-            this->formatter = NULL;
-            this->filter = NULL;
-
-            this->level = Level::FATAL;  // We take everything by default
-        }
+        StreamHandler();
 
         /**
          * Create a StreamHandler, with no current output stream.
          */
-        StreamHandler( io::OutputStream* stream, Formatter* formatter ) {
-            this->stream = stream;
-            this->formatter = formatter;
-            this->filter = NULL;
-
-            this->level = Level::Fatal;  // We take everything by default
-        }
+        StreamHandler( decaf::io::OutputStream* stream, Formatter* formatter );
 
-        virtual ~StreamHandler() {
-            try {
-                this->close();
-            }
-            DECAF_CATCH_NOTHROW( lang::Exception)
-            DECAF_CATCHALL_NOTHROW()
-        }
+        virtual ~StreamHandler();
 
         /**
          * Close the current output stream.
@@ -82,23 +73,15 @@
          * After close has been called this Handler  should no longer be used.
          * Method calls may either be silently ignored or may throw runtime
          * exceptions.
+         *
          * @throw IOException
          */
-        virtual void close() throw ( decaf::io::IOException ) {
-            if( stream ) {
-                stream.flush();
-                stream.close();
-            }
-        }
+        virtual void close() throw ( decaf::io::IOException );
 
         /**
          * Flush the Handler's output, clears any buffers.
          */
-        virtual void flush() {
-            if(stream) {
-                stream->flush();
-            }
-        }
+        virtual void flush();
 
         /**
          * Publish the Log Record to this Handler
@@ -106,55 +89,24 @@
          * @param record
          *      The <code>LogRecord</code> to Publish
          */
-        virtual void publish( const LogRecord& record ) {
-
-            try {
-
-                if( !stream ) {
-                    throw lang::exceptions::NullPointerException(
-                        __FILE__, __LINE__,
-                        "StreamHandler::publish - Stream not set.");
-                }
-
-                // Check if we should log this record
-                if(isLoggable( record) ) {
-
-                    std::string log = formatter->format(record);
-
-                    synchronized(stream) {
-                        // Write the data to the stream
-                        stream->write(log.c_str(), log.length());
-                    }
-                }
-            }
-            DECAF_CATCH_RETHROW( lang::Exception )
-            DECAF_CATCHALL_THROW( lang::Exception )
-        }
+        virtual void publish( const LogRecord& record );
 
         /**
          * Check if this Handler would actually log a given LogRecord.
          * <p>
          * @param record
          *      <code>LogRecord</code> to check
+         *
+         * @return true if the record can be logged with current settings.
          */
-        virtual void isLoggable( const LogRecord& record ) {
-
-            if( filter ) {
-                // Allow for some filtering to occur
-                return filter->isLoggable( record );
-            }
-
-            // By default we want everything that is greater than or
-            // equal to the set level of this Handler.
-            return record.level >= level;
-        }
+        virtual bool isLoggable( const LogRecord& record ) const;
 
         /**
          * Sets the Filter that this Handler uses to filter Log Records
          * @param filter
          *      <code>Filter</code> derived instance
          */
-        virtual void setFilter( const Filter* filter ){
+        virtual void setFilter( Filter* filter ) {
             this->filter = filter;
         }
 
@@ -162,7 +114,7 @@
          * Gets the Filter that this Handler uses to filter Log Records
          * @return <code>Filter</code> derived instance
          */
-        virtual const Filter* getFilter(){
+        virtual const Filter* getFilter() {
             return filter;
         }
 
@@ -176,7 +128,7 @@
          * @param level
          *      Level enumeration value
          */
-        virtual void setLevel( Level level ){
+        virtual void setLevel( Level level ) {
             this->level = level;
         }
 
@@ -185,7 +137,7 @@
          * by this Handler.
          * @return Currently set Level enumeration value
          */
-        virtual Level getLevel(){
+        virtual Level getLevel() {
             return level;
         }
 
@@ -194,7 +146,7 @@
          * @param formatter
          *      <code>Formatter</code> derived instance
          */
-        virtual void setFormatter( const Formatter* formatter ){
+        virtual void setFormatter( Formatter* formatter ){
             this->formatter = formatter;
         }
 
@@ -214,6 +166,26 @@
             return stream;
         }
 
+        /**
+         * Sets the <code>Formatter</code> used by this Handler
+         * <p>
+         * The ErrorManager's "error" method will be invoked if any errors occur while
+         * using this Handler.
+         *
+         * @param errorManager <code>ErrorManager</code> derived instance
+         */
+        virtual void setErrorManager( ErrorManager* errorManager ) {
+            this->errorManager = errorManager;
+        }
+
+        /**
+         * Gets the <code>ErrorManager</code> used by this Handler.
+         * @returns <code>ErrorManager</code> derived pointer or NULL.
+         */
+        virtual const ErrorManager* getErrorManager() {
+            return this->errorManager;
+        }
+
     };
 
 }}}



Mime
View raw message