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 
80  static const int COUNT=unspecified+1;
81 
84  static bool isCategory(const std::string& name);
85 
89  static Category category(const char* name);
90 
94  static Category category(const std::string& name) {
95  return category(name.c_str());
96  }
97 
99  static const char* name(Category);
100 };
101 
102 
104 public:
106  hintList.push_back(std::make_pair("AsynchIo", network));
107  hintList.push_back(std::make_pair("TCP", network));
108  hintList.push_back(std::make_pair("epoll", network));
109  hintList.push_back(std::make_pair("Pollable", network));
110  hintList.push_back(std::make_pair("Socket", network));
111 
112  hintList.push_back(std::make_pair("Sasl", security));
113  hintList.push_back(std::make_pair("Ssl", security));
114  hintList.push_back(std::make_pair("Acl", security));
115  hintList.push_back(std::make_pair("acl", security));
116  hintList.push_back(std::make_pair("cyrus", security));
117 
118  hintList.push_back(std::make_pair("amqp_", protocol));
119  hintList.push_back(std::make_pair("framing", protocol));
120 
121  hintList.push_back(std::make_pair("management", management));
122  hintList.push_back(std::make_pair("qmf", management));
123  hintList.push_back(std::make_pair("console", management));
124  hintList.push_back(std::make_pair("Management", management));
125 
126  hintList.push_back(std::make_pair("cluster", ha));
127  hintList.push_back(std::make_pair("qpid/ha", ha));
128  hintList.push_back(std::make_pair("qpid\\ha", ha));
129  hintList.push_back(std::make_pair("replication", ha));
130  hintList.push_back(std::make_pair("ClusterSafe", ha));
131 
132  hintList.push_back(std::make_pair("broker", broker));
133  hintList.push_back(std::make_pair("SessionState",broker));
134  hintList.push_back(std::make_pair("DataDir", broker));
135  hintList.push_back(std::make_pair("qpidd", broker));
136  hintList.push_back(std::make_pair("xml", broker));
137  hintList.push_back(std::make_pair("QpidBroker", broker));
138 
139  hintList.push_back(std::make_pair("store", store));
140 
141  hintList.push_back(std::make_pair("assert", system));
142  hintList.push_back(std::make_pair("Exception", system));
143  hintList.push_back(std::make_pair("sys", system));
144  hintList.push_back(std::make_pair("SCM", system));
145 
146  hintList.push_back(std::make_pair("tests", test));
147 
148  hintList.push_back(std::make_pair("messaging", messaging));
149  hintList.push_back(std::make_pair("types", messaging));
150 
151  hintList.push_back(std::make_pair("client", client));
152  }
153 
154  static Category categoryOf(const char*const fName);
155 
156 private:
157  std::list<std::pair<const char* const, Category> > hintList;
158 };
159 
161 struct Statement {
162  bool enabled;
163  const char* file;
164  int line;
165  const char* function;
168 
169  QPID_COMMON_EXTERN void log(const std::string& message);
170  QPID_COMMON_EXTERN static void categorize(Statement& s);
171 
172  struct Initializer {
175  };
176 };
177 
179 #define QPID_LOG_STATEMENT_INIT_CAT(LEVEL, CATEGORY) \
180 { 0, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, (::qpid::log::LEVEL), \
181 (::qpid::log::CATEGORY) }
182 
183 
185 #define QPID_LOG_STATEMENT_INIT(LEVEL) \
186 QPID_LOG_STATEMENT_INIT_CAT ( LEVEL , unspecified )
187 
199 #define QPID_LOG_IF(LEVEL, TEST, MESSAGE) \
200  do { \
201  using ::qpid::log::Statement; \
202  static Statement stmt_= QPID_LOG_STATEMENT_INIT(LEVEL); \
203  static Statement::Initializer init_(stmt_); \
204  if (stmt_.enabled && (TEST)) \
205  stmt_.log(::qpid::Msg() << MESSAGE); \
206  } while(0)
207 
212 #define QPID_LOG_IF_CAT(LEVEL, CATEGORY, TEST, MESSAGE) \
213  do { \
214  using ::qpid::log::Statement; \
215  static Statement stmt_= QPID_LOG_STATEMENT_INIT_CAT(LEVEL, CATEGORY); \
216  static Statement::Initializer init_(stmt_); \
217  if (stmt_.enabled && (TEST)) \
218  stmt_.log(::qpid::Msg() << MESSAGE); \
219  } while(0)
220 
231 #define QPID_LOG_TEST(LEVEL, FLAG) \
232  do { \
233  using ::qpid::log::Statement; \
234  static Statement stmt_= QPID_LOG_STATEMENT_INIT(LEVEL); \
235  static Statement::Initializer init_(stmt_); \
236  FLAG = stmt_.enabled; \
237  } while(0)
238 
249  #define QPID_LOG_TEST_CAT(LEVEL, CATEGORY, FLAG) \
250  do { \
251  using ::qpid::log::Statement; \
252  static Statement stmt_= QPID_LOG_STATEMENT_INIT_CAT(LEVEL, CATEGORY); \
253  static Statement::Initializer init_(stmt_); \
254  FLAG = stmt_.enabled; \
255  } while(0)
256 
273 #define QPID_LOG(LEVEL, MESSAGE) QPID_LOG_IF(LEVEL, true, MESSAGE);
274 
292 #define QPID_LOG_CAT(LEVEL, CATEGORY, MESSAGE) QPID_LOG_IF_CAT(LEVEL, CATEGORY, true, MESSAGE);
293 
294 }} // namespace qpid::log
295 
296 
297 
298 
299 #endif

Qpid C++ API Reference
Generated on Thu Jan 10 2013 for Qpid C++ Client API by doxygen 1.8.1.1