Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET Apache Qpid Documentation
Statement.h
Go to the documentation of this file.
1 #ifndef STATEMENT_H
2 #define STATEMENT_H
3 
4 /*
5  *
6  * Copyright (c) 2006 The Apache Software Foundation
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 
22 #include "qpid/Msg.h"
24 #include <boost/current_function.hpp>
25 #include <list>
26 
27 namespace qpid {
28 namespace log {
29 
40 struct LevelTraits {
41  static const int COUNT=critical+1;
42 
46  static Level level(const char* name);
47 
51  static Level level(const std::string& name) {
52  return level(name.c_str());
53  }
54 
56  static const char* name(Level);
57 };
58 
81  static const int COUNT=unspecified+1;
82 
85  static bool isCategory(const std::string& name);
86 
90  static Category category(const char* name);
91 
95  static Category category(const std::string& name) {
96  return category(name.c_str());
97  }
98 
100  static const char* name(Category);
101 };
102 
103 
105 public:
107  hintList.push_back(std::make_pair("AsynchIo", network));
108  hintList.push_back(std::make_pair("TCP", network));
109  hintList.push_back(std::make_pair("epoll", network));
110  hintList.push_back(std::make_pair("Pollable", network));
111  hintList.push_back(std::make_pair("Socket", network));
112 
113  hintList.push_back(std::make_pair("Sasl", security));
114  hintList.push_back(std::make_pair("Ssl", security));
115  hintList.push_back(std::make_pair("Acl", security));
116  hintList.push_back(std::make_pair("acl", security));
117  hintList.push_back(std::make_pair("cyrus", security));
118 
119  hintList.push_back(std::make_pair("amqp_", protocol));
120  hintList.push_back(std::make_pair("framing", protocol));
121 
122  hintList.push_back(std::make_pair("management", management));
123  hintList.push_back(std::make_pair("qmf", management));
124  hintList.push_back(std::make_pair("console", management));
125  hintList.push_back(std::make_pair("Management", management));
126 
127  hintList.push_back(std::make_pair("cluster", ha));
128  hintList.push_back(std::make_pair("qpid/ha", ha));
129  hintList.push_back(std::make_pair("qpid\\ha", ha));
130  hintList.push_back(std::make_pair("replication", ha));
131  hintList.push_back(std::make_pair("ClusterSafe", ha));
132 
133  hintList.push_back(std::make_pair("broker", broker));
134  hintList.push_back(std::make_pair("SessionState",broker));
135  hintList.push_back(std::make_pair("DataDir", broker));
136  hintList.push_back(std::make_pair("qpidd", broker));
137  hintList.push_back(std::make_pair("xml", broker));
138  hintList.push_back(std::make_pair("QpidBroker", broker));
139 
140  hintList.push_back(std::make_pair("store", store));
141 
142  hintList.push_back(std::make_pair("assert", system));
143  hintList.push_back(std::make_pair("Exception", system));
144  hintList.push_back(std::make_pair("sys", system));
145  hintList.push_back(std::make_pair("SCM", system));
146 
147  hintList.push_back(std::make_pair("tests", test));
148 
149  hintList.push_back(std::make_pair("messaging", messaging));
150  hintList.push_back(std::make_pair("types", messaging));
151 
152  hintList.push_back(std::make_pair("client", client));
153  }
154 
155  static Category categoryOf(const char*const fName);
156 
157 private:
158  std::list<std::pair<const char* const, Category> > hintList;
159 };
160 
162 struct Statement {
163  bool enabled;
164  const char* file;
165  int line;
166  const char* function;
169 
170  QPID_COMMON_EXTERN void log(const std::string& message);
171  QPID_COMMON_EXTERN static void categorize(Statement& s);
172 
173  struct Initializer {
176  };
177 };
178 
180 #define QPID_LOG_STATEMENT_INIT_CAT(LEVEL, CATEGORY) \
181 { 0, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, (::qpid::log::LEVEL), \
182 (::qpid::log::CATEGORY) }
183 
184 
186 #define QPID_LOG_STATEMENT_INIT(LEVEL) \
187 QPID_LOG_STATEMENT_INIT_CAT ( LEVEL , unspecified )
188 
200 #define QPID_LOG_IF(LEVEL, TEST, MESSAGE) \
201  do { \
202  using ::qpid::log::Statement; \
203  static Statement stmt_= QPID_LOG_STATEMENT_INIT(LEVEL); \
204  static Statement::Initializer init_(stmt_); \
205  if (stmt_.enabled && (TEST)) \
206  stmt_.log(::qpid::Msg() << MESSAGE); \
207  } while(0)
208 
213 #define QPID_LOG_IF_CAT(LEVEL, CATEGORY, TEST, MESSAGE) \
214  do { \
215  using ::qpid::log::Statement; \
216  static Statement stmt_= QPID_LOG_STATEMENT_INIT_CAT(LEVEL, CATEGORY); \
217  static Statement::Initializer init_(stmt_); \
218  if (stmt_.enabled && (TEST)) \
219  stmt_.log(::qpid::Msg() << MESSAGE); \
220  } while(0)
221 
232 #define QPID_LOG_TEST(LEVEL, FLAG) \
233  do { \
234  using ::qpid::log::Statement; \
235  static Statement stmt_= QPID_LOG_STATEMENT_INIT(LEVEL); \
236  static Statement::Initializer init_(stmt_); \
237  FLAG = stmt_.enabled; \
238  } while(0)
239 
250  #define QPID_LOG_TEST_CAT(LEVEL, CATEGORY, FLAG) \
251  do { \
252  using ::qpid::log::Statement; \
253  static Statement stmt_= QPID_LOG_STATEMENT_INIT_CAT(LEVEL, CATEGORY); \
254  static Statement::Initializer init_(stmt_); \
255  FLAG = stmt_.enabled; \
256  } while(0)
257 
274 #define QPID_LOG(LEVEL, MESSAGE) QPID_LOG_IF(LEVEL, true, MESSAGE);
275 
293 #define QPID_LOG_CAT(LEVEL, CATEGORY, MESSAGE) QPID_LOG_IF_CAT(LEVEL, CATEGORY, true, MESSAGE);
294 
295 }} // namespace qpid::log
296 
297 
298 
299 
300 #endif

Qpid C++ API Reference
Generated on Mon Feb 11 2013 for Qpid C++ Client API by doxygen 1.8.1.1