You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-dev@logging.apache.org by ca...@apache.org on 2008/02/14 18:24:34 UTC

svn commit: r627809 - /logging/log4cxx/trunk/src/examples/cpp/trivial.cpp

Author: carnold
Date: Thu Feb 14 09:24:30 2008
New Revision: 627809

URL: http://svn.apache.org/viewvc?rev=627809&view=rev
Log:
LOGCXX-1: Ant build tweaks for libesmtp

Modified:
    logging/log4cxx/trunk/src/examples/cpp/trivial.cpp

Modified: logging/log4cxx/trunk/src/examples/cpp/trivial.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/examples/cpp/trivial.cpp?rev=627809&r1=627808&r2=627809&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/examples/cpp/trivial.cpp (original)
+++ logging/log4cxx/trunk/src/examples/cpp/trivial.cpp Thu Feb 14 09:24:30 2008
@@ -14,29 +14,40 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
+#include <log4cxx/logstring.h>
+#include <stdlib.h>
 #include <log4cxx/logger.h>
 #include <log4cxx/basicconfigurator.h>
+#include <log4cxx/helpers/exception.h>
+#include <log4cxx/ndc.h>
+#include <locale.h>
 
 using namespace log4cxx;
+using namespace log4cxx::helpers;
 
-struct Foo {
-  Foo(const char *prefix):
-    logger (Logger::getLogger ("foo")), prefix (prefix)
-    {}
-  ~Foo()
+int main()
+{
+    setlocale(LC_ALL, "");
+    int result = EXIT_SUCCESS;
+    try
     {
-      LOG4CXX_DEBUG (logger, "dtor");
-    }
-  LoggerPtr logger;
-  const char *prefix;
-};
+                BasicConfigurator::configure();
+                LoggerPtr rootLogger = Logger::getRootLogger();
 
+                NDC::push("trivial context");
 
-Foo global ("global: ");
-int main()
-{
-  BasicConfigurator::configure();
-  Foo local ("local: ");
-  return 0;
+                LOG4CXX_DEBUG(rootLogger, "debug message");
+                LOG4CXX_INFO(rootLogger, "info message");
+                LOG4CXX_WARN(rootLogger, "warn message");
+                LOG4CXX_ERROR(rootLogger, "error message");
+                LOG4CXX_FATAL(rootLogger, "fatal message");
+
+                NDC::pop();
+        }
+        catch(std::exception&)
+        {
+                result = EXIT_FAILURE;
+        }
+
+    return result;
 }