Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET
Apache Qpid Documentation
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
qpid
log
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
"
23
#include "
qpid/CommonImportExport.h
"
24
#include <boost/current_function.hpp>
25
26
namespace
qpid {
27
namespace
log {
28
38
enum
Level
{
trace
,
debug
,
info
,
notice
,
warning
,
error
,
critical
};
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
77
enum
Category
{
security
,
broker
,
management
,
protocol
,
system
,
ha
,
messaging
,
78
store
,
network
,
test
,
client
,
model
,
unspecified
};
79
struct
CategoryTraits
{
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
;
108
Level
level
;
109
Category
category
;
110
111
QPID_COMMON_EXTERN
void
log
(
const
std::string& message);
112
QPID_COMMON_EXTERN
static
void
categorize
(
Statement
& s);
113
114
struct
Initializer
{
115
QPID_COMMON_EXTERN
Initializer
(
Statement
& s);
116
Statement
&
statement
;
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
Qpid C++ API Reference
Generated on Tue Sep 2 2014 for Qpid C++ Client API by
1.8.3.1