From 928b806b8bc238de9222bd81e7fba950494588b7 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 25 Sep 2008 14:16:51 +0000 Subject: Added ScopedSuppressLogging, used to suppress expected error messages in tests. For examples see src/tests/exception_test.cpp git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@698981 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/log/Logger.cpp | 2 +- cpp/src/qpid/log/Logger.h | 17 ++++++++++------- cpp/src/qpid/log/Options.cpp | 19 ++++++++++++++++++- cpp/src/qpid/log/Options.h | 4 +++- 4 files changed, 32 insertions(+), 10 deletions(-) (limited to 'cpp/src/qpid') diff --git a/cpp/src/qpid/log/Logger.cpp b/cpp/src/qpid/log/Logger.cpp index 54df54bb94..b4f5bde186 100644 --- a/cpp/src/qpid/log/Logger.cpp +++ b/cpp/src/qpid/log/Logger.cpp @@ -17,7 +17,6 @@ */ #include "Logger.h" -#include "Options.h" #include "qpid/memory.h" #include "qpid/sys/Thread.h" #include @@ -212,6 +211,7 @@ void Logger::add(Statement& s) { } void Logger::configure(const Options& opts) { + options = opts; clear(); Options o(opts); if (o.trace) diff --git a/cpp/src/qpid/log/Logger.h b/cpp/src/qpid/log/Logger.h index fa38678bba..3201eac98f 100644 --- a/cpp/src/qpid/log/Logger.h +++ b/cpp/src/qpid/log/Logger.h @@ -1,5 +1,5 @@ -#ifndef LOGGER_H -#define LOGGER_H +#ifndef QPID_LOG_LOGGER_H +#define QPID_LOG_LOGGER_H /* * http://www.apache.org/licenses/LICENSE-2.0 @@ -13,6 +13,7 @@ */ #include "Selector.h" +#include "Options.h" #include "qpid/sys/Mutex.h" #include #include @@ -21,8 +22,6 @@ namespace qpid { namespace log { -class Options; - /** * Central logging agent. * @@ -93,10 +92,13 @@ class Logger : private boost::noncopyable { /** Set a prefix for all messages */ void setPrefix(const std::string& prefix); - /** Reset the logger to it's original state. */ + /** Reset the logger. */ void clear(); - + /** Get the options used to configure the logger. */ + const Options& getOptions() const { return options; } + + private: typedef boost::ptr_vector Outputs; typedef std::set Statements; @@ -109,9 +111,10 @@ class Logger : private boost::noncopyable { Selector selector; int flags; std::string prefix; + Options options; }; }} // namespace qpid::log -#endif /*!LOGGER_H*/ +#endif /*!QPID_LOG_LOGGER_H*/ diff --git a/cpp/src/qpid/log/Options.cpp b/cpp/src/qpid/log/Options.cpp index e28f82648e..a850ea470d 100644 --- a/cpp/src/qpid/log/Options.cpp +++ b/cpp/src/qpid/log/Options.cpp @@ -146,6 +146,23 @@ Options::Options(const std::string& argv0, const std::string& name) : ("syslog-name", optValue(syslogName, "NAME"), "Name to use in syslog messages") ("syslog-facility", optValue(syslogFacility,"LOG_XXX"), "Facility to use in syslog messages") ; -} +} + +Options& Options::operator=(const Options& x) { + if (this != &x) { + selectors = x.selectors; + outputs = x.outputs; + time = x.time; + level= x.level; + thread = x.thread; + source = x.source; + function = x.function; + trace = x.trace; + syslogName = x.syslogName; + syslogFacility = x.syslogFacility; + prefix = x.prefix; + } + return *this; +} }} // namespace qpid::log diff --git a/cpp/src/qpid/log/Options.h b/cpp/src/qpid/log/Options.h index 13fca38f9d..3d128b5668 100644 --- a/cpp/src/qpid/log/Options.h +++ b/cpp/src/qpid/log/Options.h @@ -36,9 +36,11 @@ std::istream& operator>>(std::istream&, SyslogFacility&); /** Logging options for config parser. */ struct Options : public qpid::Options { /** Pass argv[0] for use in syslog output */ - Options(const std::string& argv0, + Options(const std::string& argv0=std::string(), const std::string& name="Logging options"); + Options& operator=(const Options&); + std::vector selectors; std::vector outputs; bool time, level, thread, source, function; -- cgit v1.2.1