Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _LOG4CPP_CATEGORY_HH
00011 #define _LOG4CPP_CATEGORY_HH
00012
00013 #include <log4cpp/Portability.hh>
00014 #include <log4cpp/Appender.hh>
00015 #include <log4cpp/LoggingEvent.hh>
00016 #include <log4cpp/Priority.hh>
00017 #include <log4cpp/CategoryStream.hh>
00018 #include <log4cpp/threading/Threading.hh>
00019 #include <log4cpp/convenience.h>
00020
00021 #include <map>
00022 #include <vector>
00023 #include <cstdarg>
00024 #include <stdexcept>
00025
00026 namespace log4cpp {
00027
00033 class LOG4CPP_EXPORT Category {
00034 friend class HierarchyMaintainer;
00035
00036 public:
00048 static Category& getRoot();
00049
00054 static void setRootPriority(Priority::Value priority);
00055
00060 static Priority::Value getRootPriority() throw();
00061
00069 static Category& getInstance(const std::string& name);
00070
00076 static Category* exists(const std::string& name);
00077
00090 static std::vector<Category*>* getCurrentCategories();
00091
00095 static void shutdown();
00096
00100 virtual ~Category();
00101
00106 virtual const std::string& getName() const throw();
00107
00115 virtual void setPriority(Priority::Value priority)
00116 throw(std::invalid_argument);
00117
00122 virtual Priority::Value getPriority() const throw();
00123
00132 virtual Priority::Value getChainedPriority() const throw();
00133
00140 virtual bool isPriorityEnabled(Priority::Value priority) const throw();
00141
00149 virtual void addAppender(Appender* appender)
00150 throw(std::invalid_argument);
00151
00158 virtual void addAppender(Appender& appender);
00159
00168 inline void setAppender(Appender* appender) {
00169 if (appender) {
00170 addAppender(appender);
00171 } else {
00172 removeAllAppenders();
00173 }
00174 };
00175
00182 inline void setAppender(Appender& appender) {
00183 addAppender(appender);
00184 };
00185
00192 virtual Appender* getAppender() const;
00193
00200 virtual Appender* getAppender(const std::string& name) const;
00201
00207 virtual AppenderSet getAllAppenders() const;
00208
00212 virtual void removeAllAppenders();
00213
00218 virtual void removeAppender(Appender* appender);
00219
00226 virtual bool ownsAppender() const throw() {
00227 return ownsAppender(getAppender());
00228 };
00229
00235 virtual bool ownsAppender(Appender* appender) const throw();
00236
00248 virtual void callAppenders(const LoggingEvent& event) throw();
00249
00253 virtual void setAdditivity(bool additivity);
00254
00258 virtual bool getAdditivity() const throw();
00259
00265 virtual Category* getParent() throw();
00266
00272 virtual const Category* getParent() const throw();
00273
00281 virtual void log(Priority::Value priority, const char* stringFormat,
00282 ...) throw();
00283
00289 virtual void log(Priority::Value priority,
00290 const std::string& message) throw();
00291
00300 virtual void logva(Priority::Value priority,
00301 const char* stringFormat,
00302 va_list va) throw();
00303
00310 void debug(const char* stringFormat, ...) throw();
00311
00316 void debug(const std::string& message) throw();
00317
00322 inline bool isDebugEnabled() const throw() {
00323 return isPriorityEnabled(Priority::DEBUG);
00324 };
00325
00330 inline CategoryStream debugStream() {
00331 return getStream(Priority::DEBUG);
00332 }
00333
00340 void info(const char* stringFormat, ...) throw();
00341
00346 void info(const std::string& message) throw();
00347
00352 inline bool isInfoEnabled() const throw() {
00353 return isPriorityEnabled(Priority::INFO);
00354 };
00355
00360 inline CategoryStream infoStream() {
00361 return getStream(Priority::INFO);
00362 }
00363
00370 void notice(const char* stringFormat, ...) throw();
00371
00376 void notice(const std::string& message) throw();
00377
00382 inline bool isNoticeEnabled() const throw() {
00383 return isPriorityEnabled(Priority::NOTICE);
00384 };
00385
00390 inline CategoryStream noticeStream() {
00391 return getStream(Priority::NOTICE);
00392 }
00393
00400 void warn(const char* stringFormat, ...) throw();
00401
00406 void warn(const std::string& message) throw();
00407
00412 inline bool isWarnEnabled() const throw() {
00413 return isPriorityEnabled(Priority::WARN);
00414 };
00415
00420 inline CategoryStream warnStream() {
00421 return getStream(Priority::WARN);
00422 };
00423
00430 void error(const char* stringFormat, ...) throw();
00431
00436 void error(const std::string& message) throw();
00437
00442 inline bool isErrorEnabled() const throw() {
00443 return isPriorityEnabled(Priority::ERROR);
00444 };
00445
00450 inline CategoryStream errorStream() {
00451 return getStream(Priority::ERROR);
00452 };
00453
00460 void crit(const char* stringFormat, ...) throw();
00461
00466 void crit(const std::string& message) throw();
00467
00472 inline bool isCritEnabled() const throw() {
00473 return isPriorityEnabled(Priority::CRIT);
00474 };
00475
00480 inline CategoryStream critStream() {
00481 return getStream(Priority::CRIT);
00482 };
00483
00490 void alert(const char* stringFormat, ...) throw();
00491
00496 void alert(const std::string& message) throw();
00497
00502 inline bool isAlertEnabled() const throw() {
00503 return isPriorityEnabled(Priority::ALERT);
00504 };
00505
00510 inline CategoryStream alertStream() throw() {
00511 return getStream(Priority::ALERT);
00512 };
00513
00520 void emerg(const char* stringFormat, ...) throw();
00521
00526 void emerg(const std::string& message) throw();
00527
00532 inline bool isEmergEnabled() const throw() {
00533 return isPriorityEnabled(Priority::EMERG);
00534 };
00535
00540 inline CategoryStream emergStream() {
00541 return getStream(Priority::EMERG);
00542 };
00543
00552 void fatal(const char* stringFormat, ...) throw();
00553
00560 void fatal(const std::string& message) throw();
00561
00568 inline bool isFatalEnabled() const throw() {
00569 return isPriorityEnabled(Priority::FATAL);
00570 };
00571
00578 inline CategoryStream fatalStream() {
00579 return getStream(Priority::FATAL);
00580 };
00581
00587 virtual CategoryStream getStream(Priority::Value priority);
00588
00594 virtual CategoryStream operator<<(Priority::Value priority);
00595
00596 protected:
00597
00606 Category(const std::string& name, Category* parent,
00607 Priority::Value priority = Priority::NOTSET);
00608
00609 virtual void _logUnconditionally(Priority::Value priority,
00610 const char* format,
00611 va_list arguments) throw();
00612
00618 virtual void _logUnconditionally2(Priority::Value priority,
00619 const std::string& message) throw();
00620
00621 private:
00622
00623
00624 Category(const Category& other);
00625 Category& operator=(const Category& other);
00626
00628 const std::string _name;
00629
00634 Category* _parent;
00635
00639 volatile Priority::Value _priority;
00640
00641 typedef std::map<Appender *, bool> OwnsAppenderMap;
00642
00649 virtual bool ownsAppender(Appender* appender,
00650 OwnsAppenderMap::iterator& i2) throw();
00651
00652 AppenderSet _appender;
00653 mutable threading::Mutex _appenderSetMutex;
00654
00660 OwnsAppenderMap _ownsAppender;
00661
00666 volatile bool _isAdditive;
00667
00668 };
00669
00670 }
00671 #endif // _LOG4CPP_CATEGORY_HH
log4cpp
Author(s): Stephen Roderick, Bastiaan Bakker, Cedric Le Goater, Steve Ostlind, Marcel Harkema, Walter Stroebel, Glenn Scott and Tony Cheung.
autogenerated on Thu Jan 2 2014 11:35:02