activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r906971 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging: ErrorManager.cpp ErrorManager.h
Date Fri, 05 Feb 2010 15:30:22 GMT
Author: tabish
Date: Fri Feb  5 15:30:22 2010
New Revision: 906971

URL: http://svn.apache.org/viewvc?rev=906971&view=rev
Log:
Completed implementation of ErrorManager for Logging package.

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ErrorManager.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ErrorManager.h

Modified: 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=906971&r1=906970&r2=906971&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ErrorManager.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ErrorManager.cpp
Fri Feb  5 15:30:22 2010
@@ -17,19 +17,57 @@
 
 #include "ErrorManager.h"
 
+#include <iostream>
+
+using namespace std;
 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;
+const int ErrorManager::GENERIC_FAILURE = 0;
+const int ErrorManager::WRITE_FAILURE = 1;
+const int ErrorManager::FLUSH_FAILURE = 2;
+const int ErrorManager::CLOSE_FAILURE = 3;
+const int ErrorManager::OPEN_FAILURE = 4;
+const int ErrorManager::FORMAT_FAILURE = 5;
+
+////////////////////////////////////////////////////////////////////////////////
+namespace {
+
+    std::string FAILURE_STRINGS[] = {
+       "GENERIC_FAILURE",
+       "WRITE_FAILURE",
+       "FLUSH_FAILURE",
+       "CLOSE_FAILURE",
+       "OPEN_FAILURE",
+       "FORMAT_FAILURE"
+    };
+}
+
+////////////////////////////////////////////////////////////////////////////////
+ErrorManager::ErrorManager() : wasCalled( false ) {
+}
 
 ////////////////////////////////////////////////////////////////////////////////
 ErrorManager::~ErrorManager() {
 }
+
+////////////////////////////////////////////////////////////////////////////////
+void ErrorManager::error( const std::string& message, decaf::lang::Exception* ex, int
code ) {
+
+    if( !wasCalled.compareAndSet( false, true ) ) {
+        return;
+    }
+
+    std::cerr << "ErrorManager: " << FAILURE_STRINGS[code] << std::endl;
+
+    if( message != "" ) {
+        std::cerr << "ErrorManager: message = " << message << std::endl;
+    }
+
+    if( ex != NULL ) {
+        std::cerr << "ErrorManager: Exception Message = " << ex->getMessage()
<< std::endl;
+    }
+}

Modified: 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=906971&r1=906970&r2=906971&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ErrorManager.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/logging/ErrorManager.h Fri
Feb  5 15:30:22 2010
@@ -21,6 +21,8 @@
 #include <decaf/util/Config.h>
 #include <decaf/lang/Exception.h>
 
+#include <decaf/util/concurrent/atomic/AtomicBoolean.h>
+
 #include <string>
 
 namespace decaf {
@@ -38,6 +40,10 @@
      * @since 1.0
      */
     class DECAF_API ErrorManager {
+    private:
+
+        decaf::util::concurrent::atomic::AtomicBoolean wasCalled;
+
     public:
 
         /**
@@ -72,6 +78,8 @@
 
     public:
 
+        ErrorManager();
+
         virtual ~ErrorManager();
 
         /**
@@ -80,11 +88,11 @@
          * 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 msg - a descriptive string (may be empty)
+         * @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;
+        virtual void error( const std::string& message, decaf::lang::Exception* ex, int
code );
 
     };
 



Mime
View raw message