diff options
Diffstat (limited to 'cpp/src/qpid/log')
| -rw-r--r-- | cpp/src/qpid/log/Logger.cpp | 21 | ||||
| -rw-r--r-- | cpp/src/qpid/log/Options.cpp | 4 | ||||
| -rw-r--r-- | cpp/src/qpid/log/Statement.cpp | 5 | ||||
| -rw-r--r-- | cpp/src/qpid/log/posix/SinkOptions.cpp | 2 | ||||
| -rw-r--r-- | cpp/src/qpid/log/windows/SinkOptions.cpp | 4 | ||||
| -rw-r--r-- | cpp/src/qpid/log/windows/SinkOptions.h | 2 |
6 files changed, 13 insertions, 25 deletions
diff --git a/cpp/src/qpid/log/Logger.cpp b/cpp/src/qpid/log/Logger.cpp index 1600822142..2217cdddbd 100644 --- a/cpp/src/qpid/log/Logger.cpp +++ b/cpp/src/qpid/log/Logger.cpp @@ -22,7 +22,6 @@ #include "qpid/memory.h" #include "qpid/sys/Thread.h" #include "qpid/sys/Time.h" -#include "qpid/DisableExceptionLogging.h" #include <boost/pool/detail/singleton.hpp> #include <boost/bind.hpp> #include <boost/function.hpp> @@ -49,16 +48,11 @@ Logger& Logger::instance() { } Logger::Logger() : flags(0) { - // Disable automatic logging in Exception constructors to avoid - // re-entrant use of logger singleton if there is an error in - // option parsing. - DisableExceptionLogging del; - // Initialize myself from env variables so all programs // (e.g. tests) can use logging even if they don't parse // command line args. Options opts(""); - opts.parse(0, 0); + opts.parse(0, 0); configure(opts); } @@ -79,12 +73,8 @@ void Logger::log(const Statement& s, const std::string& msg) { std::ostringstream os; if (!prefix.empty()) os << prefix << ": "; - if (flags&TIME) { - if (flags&HIRES) - qpid::sys::outputHiresNow(os); - else - qpid::sys::outputFormattedNow(os); - } + if (flags&TIME) + qpid::sys::outputFormattedNow(os); if (flags&LEVEL) os << LevelTraits::name(s.level) << " "; if (flags&THREAD) @@ -133,8 +123,7 @@ int Logger::format(const Options& opts) { bitIf(opts.time, TIME) | bitIf(opts.source, (FILE|LINE)) | bitIf(opts.function, FUNCTION) | - bitIf(opts.thread, THREAD) | - bitIf(opts.hiresTs, HIRES); + bitIf(opts.thread, THREAD); format(flags); return flags; } @@ -151,7 +140,7 @@ void Logger::configure(const Options& opts) { Options o(opts); if (o.trace) o.selectors.push_back("trace+"); - format(o); + format(o); select(Selector(o)); setPrefix(opts.prefix); options.sinkOptions->setup(this); diff --git a/cpp/src/qpid/log/Options.cpp b/cpp/src/qpid/log/Options.cpp index 0001d00bdf..24ef413cbc 100644 --- a/cpp/src/qpid/log/Options.cpp +++ b/cpp/src/qpid/log/Options.cpp @@ -38,7 +38,6 @@ Options::Options(const std::string& argv0_, const std::string& name_) : thread(false), source(false), function(false), - hiresTs(false), trace(false), sinkOptions (SinkOptions::create(argv0_)) { @@ -66,7 +65,6 @@ Options::Options(const std::string& argv0_, const std::string& name_) : ("log-source", optValue(source,"yes|no"), "Include source file:line in log messages") ("log-thread", optValue(thread,"yes|no"), "Include thread ID in log messages") ("log-function", optValue(function,"yes|no"), "Include function signature in log messages") - ("log-hires-timestamp", optValue(hiresTs,"yes|no"), "Use unformatted hi-res timestamp in log messages") ("log-prefix", optValue(prefix,"STRING"), "Prefix to append to all log messages") ; add(*sinkOptions); @@ -82,7 +80,6 @@ Options::Options(const Options &o) : thread(o.thread), source(o.source), function(o.function), - hiresTs(o.hiresTs), trace(o.trace), prefix(o.prefix), sinkOptions (SinkOptions::create(o.argv0)) @@ -100,7 +97,6 @@ Options& Options::operator=(const Options& x) { thread = x.thread; source = x.source; function = x.function; - hiresTs = x.hiresTs; trace = x.trace; prefix = x.prefix; *sinkOptions = *x.sinkOptions; diff --git a/cpp/src/qpid/log/Statement.cpp b/cpp/src/qpid/log/Statement.cpp index 7dfdf08703..6a32b50096 100644 --- a/cpp/src/qpid/log/Statement.cpp +++ b/cpp/src/qpid/log/Statement.cpp @@ -27,6 +27,8 @@ namespace qpid { namespace log { namespace { +using namespace std; + struct NonPrint { bool operator()(unsigned char c) { return !isprint(c) && !isspace(c); } }; const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; @@ -37,7 +39,7 @@ std::string quote(const std::string& str) { if (n==0) return str; std::string ret; ret.reserve(str.size()+2*n); // Avoid extra allocations. - for (std::string::const_iterator i = str.begin(); i != str.end(); ++i) { + for (string::const_iterator i = str.begin(); i != str.end(); ++i) { if (nonPrint(*i)) { ret.push_back('\\'); ret.push_back('x'); @@ -48,6 +50,7 @@ std::string quote(const std::string& str) { } return ret; } + } void Statement::log(const std::string& message) { diff --git a/cpp/src/qpid/log/posix/SinkOptions.cpp b/cpp/src/qpid/log/posix/SinkOptions.cpp index ffa7633e3b..292e9147f6 100644 --- a/cpp/src/qpid/log/posix/SinkOptions.cpp +++ b/cpp/src/qpid/log/posix/SinkOptions.cpp @@ -180,7 +180,7 @@ qpid::log::SinkOptions& SinkOptions::operator=(const qpid::log::SinkOptions& rhs } void SinkOptions::detached(void) { - if (logToStderr && !logToStdout && !logToSyslog && logFile.empty()) { + if (logToStderr && !logToStdout && !logToSyslog) { logToStderr = false; logToSyslog = true; } diff --git a/cpp/src/qpid/log/windows/SinkOptions.cpp b/cpp/src/qpid/log/windows/SinkOptions.cpp index 0c74bea64e..28f4b267e0 100644 --- a/cpp/src/qpid/log/windows/SinkOptions.cpp +++ b/cpp/src/qpid/log/windows/SinkOptions.cpp @@ -53,7 +53,7 @@ static int eventTypes[qpid::log::LevelTraits::COUNT] = { class EventLogOutput : public qpid::log::Logger::Output { public: - EventLogOutput(const std::string& /*sourceName*/) : logHandle(0) + EventLogOutput(const std::string& sourceName) : logHandle(0) { logHandle = OpenEventLog(0, "Application"); } @@ -83,7 +83,7 @@ private: HANDLE logHandle; }; -SinkOptions::SinkOptions(const std::string& /*argv0*/) +SinkOptions::SinkOptions(const std::string& argv0) : qpid::log::SinkOptions(), logToStderr(true), logToStdout(false), diff --git a/cpp/src/qpid/log/windows/SinkOptions.h b/cpp/src/qpid/log/windows/SinkOptions.h index f270c504a2..605822fd46 100644 --- a/cpp/src/qpid/log/windows/SinkOptions.h +++ b/cpp/src/qpid/log/windows/SinkOptions.h @@ -26,7 +26,7 @@ namespace qpid { namespace log { namespace windows { -struct QPID_COMMON_CLASS_EXTERN SinkOptions : public qpid::log::SinkOptions { +struct SinkOptions : public qpid::log::SinkOptions { QPID_COMMON_EXTERN SinkOptions(const std::string& argv0); virtual ~SinkOptions() {} |
