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,
87 static LoggerPtr
getLogger(
const std::string& name);
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 iShouldNeverBeMatchedByClientCode; \ 213 iShouldNeverBeMatchedByClientCode << msg; \ 214 logger->trace(iShouldNeverBeMatchedByClientCode.str()); \ 217 #define RSCDEBUG(logger, msg) \ 218 if (logger->isDebugEnabled()) { \ 219 std::stringstream iShouldNeverBeMatchedByClientCode; \ 220 iShouldNeverBeMatchedByClientCode << msg; \ 221 logger->debug(iShouldNeverBeMatchedByClientCode.str()); \ 224 #define RSCINFO(logger, msg) \ 225 if (logger->isInfoEnabled()) { \ 226 std::stringstream iShouldNeverBeMatchedByClientCode; \ 227 iShouldNeverBeMatchedByClientCode << msg; \ 228 logger->info(iShouldNeverBeMatchedByClientCode.str()); \ 231 #define RSCWARN(logger, msg) \ 232 if (logger->isWarnEnabled()) { \ 233 std::stringstream iShouldNeverBeMatchedByClientCode; \ 234 iShouldNeverBeMatchedByClientCode << msg; \ 235 logger->warn(iShouldNeverBeMatchedByClientCode.str()); \ 238 #define RSCERROR(logger, msg) \ 239 if (logger->isErrorEnabled()) { \ 240 std::stringstream iShouldNeverBeMatchedByClientCode; \ 241 iShouldNeverBeMatchedByClientCode << msg; \ 242 logger->error(iShouldNeverBeMatchedByClientCode.str()); \ 245 #define RSCFATAL(logger, msg) \ 246 if (logger->isFatalEnabled()) { \ 247 std::stringstream iShouldNeverBeMatchedByClientCode; \ 248 iShouldNeverBeMatchedByClientCode << msg; \ 249 logger->fatal(iShouldNeverBeMatchedByClientCode.str()); \ 262 #define RSCTRACE_EXPECT(condition, logger, msg) \ 263 if (!(condition) && logger->isTraceEnabled()) { \ 264 std::stringstream iShouldNeverBeMatchedByClientCode; \ 265 iShouldNeverBeMatchedByClientCode << msg << "\nfailed condition: " << #condition; \ 266 logger->trace(iShouldNeverBeMatchedByClientCode.str()); \ 269 #define RSCDEBUG_EXPECT(condition, logger, msg) \ 270 if (!(condition) && logger->isDebugEnabled()) { \ 271 std::stringstream iShouldNeverBeMatchedByClientCode; \ 272 iShouldNeverBeMatchedByClientCode << msg << "\nfailed condition: " << #condition; \ 273 logger->debug(iShouldNeverBeMatchedByClientCode.str()); \ 276 #define RSCINFO_EXPECT(condition, logger, msg) \ 277 if (!(condition) && logger->isInfoEnabled()) { \ 278 std::stringstream iShouldNeverBeMatchedByClientCode; \ 279 iShouldNeverBeMatchedByClientCode << msg << "\nfailed condition: " << #condition; \ 280 logger->info(iShouldNeverBeMatchedByClientCode.str()); \ 283 #define RSCWARN_EXPECT(condition, logger, msg) \ 284 if (!(condition) && logger->isWarnEnabled()) { \ 285 std::stringstream iShouldNeverBeMatchedByClientCode; \ 286 iShouldNeverBeMatchedByClientCode << msg << "\nfailed condition: " << #condition; \ 287 logger->warn(iShouldNeverBeMatchedByClientCode.str()); \ 290 #define RSCERROR_EXPECT(condition, logger, msg) \ 291 if (!(condition) && logger->isErrorEnabled()) { \ 292 std::stringstream iShouldNeverBeMatchedByClientCode; \ 293 iShouldNeverBeMatchedByClientCode << msg << "\nfailed condition: " << #condition; \ 294 logger->error(iShouldNeverBeMatchedByClientCode.str()); \ 297 #define RSCFATAL_EXPECT(condition, logger, msg) \ 298 if (!(condition) && logger->isFatalEnabled()) { \ 299 std::stringstream iShouldNeverBeMatchedByClientCode; \ 300 iShouldNeverBeMatchedByClientCode << msg << "\nfailed condition: " << #condition; \ 301 logger->fatal(iShouldNeverBeMatchedByClientCode.str()); \ Level
Possible logging levels.
ostream & operator<<(ostream &stream, const Logger::Level &level)
Interface for logging adapters that can be used with RSC.
boost::shared_ptr< Logger > LoggerPtr