33 #include <boost/noncopyable.hpp>
34 #include <boost/shared_ptr.hpp>
36 #include "rsc/rscexports.h"
42 typedef boost::shared_ptr<Logger>
LoggerPtr;
54 class RSC_EXPORT
Logger:
public boost::noncopyable {
64 LEVEL_ALL = 0x11111111,
99 virtual Level getLevel()
const = 0;
106 virtual void setLevel(
const Level& level) = 0;
113 virtual std::string getName()
const = 0;
120 virtual void setName(
const std::string& name) = 0;
136 virtual void trace(
const std::string& msg);
143 virtual void debug(
const std::string& msg);
150 virtual void info(
const std::string& msg);
157 virtual void warn(
const std::string& msg);
164 virtual void error(
const std::string& msg);
171 virtual void fatal(
const std::string& msg);
181 virtual void log(
const Level& level,
const std::string& msg) = 0;
189 virtual bool isTraceEnabled()
const;
190 virtual bool isDebugEnabled()
const;
191 virtual bool isInfoEnabled()
const;
192 virtual bool isWarnEnabled()
const;
193 virtual bool isErrorEnabled()
const;
194 virtual bool isFatalEnabled()
const;
195 virtual bool isEnabledFor(
const Level& level)
const;
210 #define RSCTRACE(logger, msg) \
211 if (logger->isTraceEnabled()) { \
212 std::stringstream s; \
214 logger->trace(s.str()); \
217 #define RSCDEBUG(logger, msg) \
218 if (logger->isDebugEnabled()) { \
219 std::stringstream s; \
221 logger->debug(s.str()); \
224 #define RSCINFO(logger, msg) \
225 if (logger->isInfoEnabled()) { \
226 std::stringstream s; \
228 logger->info(s.str()); \
231 #define RSCWARN(logger, msg) \
232 if (logger->isWarnEnabled()) { \
233 std::stringstream s; \
235 logger->warn(s.str()); \
238 #define RSCERROR(logger, msg) \
239 if (logger->isErrorEnabled()) { \
240 std::stringstream s; \
242 logger->error(s.str()); \
245 #define RSCFATAL(logger, msg) \
246 if (logger->isFatalEnabled()) { \
247 std::stringstream s; \
249 logger->fatal(s.str()); \
262 #define RSCTRACE_EXPECT(condition, logger, msg) \
263 if (!(condition) && logger->isTraceEnabled()) { \
264 std::stringstream s; \
265 s << msg << "\nfailed condition: " << #condition; \
266 logger->trace(s.str()); \
269 #define RSCDEBUG_EXPECT(condition, logger, msg) \
270 if (!(condition) && logger->isDebugEnabled()) { \
271 std::stringstream s; \
272 s << msg << "\nfailed condition: " << #condition; \
273 logger->debug(s.str()); \
276 #define RSCINFO_EXPECT(condition, logger, msg) \
277 if (!(condition) && logger->isInfoEnabled()) { \
278 std::stringstream s; \
279 s << msg << "\nfailed condition: " << #condition; \
280 logger->info(s.str()); \
283 #define RSCWARN_EXPECT(condition, logger, msg) \
284 if (!(condition) && logger->isWarnEnabled()) { \
285 std::stringstream s; \
286 s << msg << "\nfailed condition: " << #condition; \
287 logger->warn(s.str()); \
290 #define RSCERROR_EXPECT(condition, logger, msg) \
291 if (!(condition) && logger->isErrorEnabled()) { \
292 std::stringstream s; \
293 s << msg << "\nfailed condition: " << #condition; \
294 logger->error(s.str()); \
297 #define RSCFATAL_EXPECT(condition, logger, msg) \
298 if (!(condition) && logger->isFatalEnabled()) { \
299 std::stringstream s; \
300 s << msg << "\nfailed condition: " << #condition; \
301 logger->fatal(s.str()); \