00001 #ifndef STATEMENT_H
00002 #define STATEMENT_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "qpid/Msg.h"
00023
00024 #include <boost/current_function.hpp>
00025
00026 namespace qpid {
00027 namespace log {
00028
00038 enum Level { trace, debug, info, notice, warning, error, critical };
00039 struct LevelTraits {
00040 static const int COUNT=critical+1;
00041
00045 static Level level(const char* name);
00046
00050 static Level level(const std::string& name) {
00051 return level(name.c_str());
00052 }
00053
00055 static const char* name(Level);
00056
00058 static int priority(Level);
00059 };
00060
00062 struct Statement {
00063 bool enabled;
00064 const char* file;
00065 int line;
00066 const char* function;
00067 Level level;
00068
00069 void log(const std::string& message);
00070
00071 struct Initializer {
00072 Initializer(Statement& s);
00073 Statement& statement;
00074 };
00075 };
00076
00078 #define QPID_LOG_STATEMENT_INIT(level) \
00079 { 0, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, (::qpid::log::level) }
00080
00100 #define QPID_LOG(level, message) \
00101 do { \
00102 static ::qpid::log::Statement stmt_= QPID_LOG_STATEMENT_INIT(level); \
00103 static ::qpid::log::Statement::Initializer init_(stmt_); \
00104 if (stmt_.enabled) \
00105 stmt_.log(::qpid::Msg() << message); \
00106 } while(0)
00107
00108 }}
00109
00110
00111
00112
00113 #endif