summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2010-06-28 16:48:09 +0200
committerUri Lublin <uril@redhat.com>2010-06-29 15:16:14 +0300
commit5b80cace43486fbfc9b3f31ce820bf3cd0ee249f (patch)
treea2030cce5da57a7b18d9de687626c6bea225b092
parent14f8a622d5af7837a0062cf17eda870fc82df44f (diff)
client: log warnings and errors to stderr too #580925spice-client-0.4.2-13.el6
In addition to logging to a (rolling) file (which limit is INFO). This patch adds a log4cpp::appender (limit is WARN).
-rw-r--r--client/application.cpp20
-rw-r--r--client/debug.h3
2 files changed, 15 insertions, 8 deletions
diff --git a/client/application.cpp b/client/application.cpp
index 0c0c0f4..cb56d77 100644
--- a/client/application.cpp
+++ b/client/application.cpp
@@ -2091,17 +2091,23 @@ void Application::init_logger()
return;
}
- log4cpp::Category& root = log4cpp::Category::getRoot();
#ifdef RED_DEBUG
- root.setPriority(log4cpp::Priority::DEBUG);
- root.removeAllAppenders();
- root.addAppender(new log4cpp::FileAppender("_", fd));
+ logger.setPriority(log4cpp::Priority::DEBUG);
+ logger.removeAllAppenders();
+ logger.addAppender(new log4cpp::FileAppender("_", fd));
#else
- root.setPriority(log4cpp::Priority::INFO);
- root.removeAllAppenders();
+ logger.setPriority(log4cpp::Priority::INFO);
+ logger.removeAllAppenders();
::close(fd);
- root.addAppender(new log4cpp::RollingFileAppender("_", log_file_name));
+ logger.addAppender(new log4cpp::RollingFileAppender("_", log_file_name));
#endif
+
+ /* send warnings and errors to stderr (in addition to the log file) */
+ log4cpp::Appender *err_appender = new log4cpp::OstreamAppender("__", &std::cerr);
+ log4cpp::SimpleLayout *layout = new log4cpp::SimpleLayout();
+ err_appender->setThreshold(log4cpp::Priority::WARN);
+ err_appender->setLayout(layout);
+ logger.addAppender(err_appender);
}
void Application::init_globals()
diff --git a/client/debug.h b/client/debug.h
index 1c6f6a4..2c284c8 100644
--- a/client/debug.h
+++ b/client/debug.h
@@ -22,8 +22,9 @@
#include <sstream>
#include <log4cpp/Category.hh>
+#include <log4cpp/OstreamAppender.hh>
+#include <log4cpp/SimpleLayout.hh>
#include <log4cpp/convenience.h>
-
#include "platform.h"
#ifdef WIN32