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 
26 namespace qpid {
27 namespace log {
28 
39 struct LevelTraits {
40  static const int COUNT=critical+1;
41 
45  static Level level(const char* name);
46 
50  static Level level(const std::string& name) {
51  return level(name.c_str());
52  }
53 
55  static const char* name(Level);
56 };
57 
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 
103 struct Statement {
104  bool enabled;
105  const char* file;
106  int line;
107  const char* function;
110 
111  QPID_COMMON_EXTERN void log(const std::string& message);
112  QPID_COMMON_EXTERN static void categorize(Statement& s);
113 
114  struct Initializer {
117  };
118 };
119 
121 #define QPID_LOG_STATEMENT_INIT_CAT(LEVEL, CATEGORY) \
122 { 0, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, (::qpid::log::LEVEL), \
123 (::qpid::log::CATEGORY) }
124 
125 
127 #define QPID_LOG_STATEMENT_INIT(LEVEL) \
128 QPID_LOG_STATEMENT_INIT_CAT ( LEVEL , unspecified )
129 
141 #define QPID_LOG_IF(LEVEL, TEST, MESSAGE) \
142  do { \
143  using ::qpid::log::Statement; \
144  static Statement stmt_= QPID_LOG_STATEMENT_INIT(LEVEL); \
145  static Statement::Initializer init_(stmt_); \
146  if (stmt_.enabled && (TEST)) \
147  stmt_.log(::qpid::Msg() << MESSAGE); \
148  } while(0)
149 
154 #define QPID_LOG_IF_CAT(LEVEL, CATEGORY, TEST, MESSAGE) \
155  do { \
156  using ::qpid::log::Statement; \
157  static Statement stmt_= QPID_LOG_STATEMENT_INIT_CAT(LEVEL, CATEGORY); \
158  static Statement::Initializer init_(stmt_); \
159  if (stmt_.enabled && (TEST)) \
160  stmt_.log(::qpid::Msg() << MESSAGE); \
161  } while(0)
162 
173 #define QPID_LOG_TEST(LEVEL, FLAG) \
174  do { \
175  using ::qpid::log::Statement; \
176  static Statement stmt_= QPID_LOG_STATEMENT_INIT(LEVEL); \
177  static Statement::Initializer init_(stmt_); \
178  FLAG = stmt_.enabled; \
179  } while(0)
180 
191  #define QPID_LOG_TEST_CAT(LEVEL, CATEGORY, FLAG) \
192  do { \
193  using ::qpid::log::Statement; \
194  static Statement stmt_= QPID_LOG_STATEMENT_INIT_CAT(LEVEL, CATEGORY); \
195  static Statement::Initializer init_(stmt_); \
196  FLAG = stmt_.enabled; \
197  } while(0)
198 
215 #define QPID_LOG(LEVEL, MESSAGE) QPID_LOG_IF(LEVEL, true, MESSAGE);
216 
234 #define QPID_LOG_CAT(LEVEL, CATEGORY, MESSAGE) QPID_LOG_IF_CAT(LEVEL, CATEGORY, true, MESSAGE);
235 
236 }} // namespace qpid::log
237 
238 
239 
240 
241 #endif
static const int COUNT
Definition: Statement.h:40
static const int COUNT
Definition: Statement.h:80
void log(const std::string &message)
static const char * name(Category)
String name of category.
static bool isCategory(const std::string &name)
Test if given name is a Category name.
static const char * name(Level)
String name of level.
Level
Debugging severity levels.
Definition: Statement.h:38
static Level level(const char *name)
Get level from string name.
static Level level(const std::string &name)
Get level from string name.
Definition: Statement.h:50
POD struct representing a logging statement in source code.
Definition: Statement.h:103
static Category category(const std::string &name)
Get category from string name.
Definition: Statement.h:94
Category
Formal message categories https://issues.apache.org/jira/browse/QPID-3902.
Definition: Statement.h:77
static void categorize(Statement &s)
static Category category(const char *name)
Get category from string name name invalid.
const char * file
Definition: Statement.h:105
#define QPID_COMMON_EXTERN

Qpid C++ API Reference
Generated on Fri Nov 1 2013 for Qpid C++ Client API by doxygen 1.8.5