Category.hh
Go to the documentation of this file.
1 /*
2  * Category.hh
3  *
4  * Copyright 2000, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
5  * Copyright 2000, Bastiaan Bakker. All rights reserved.
6  *
7  * See the COPYING file for the terms of usage and distribution.
8  */
9 
10 #ifndef _LOG4CPP_CATEGORY_HH
11 #define _LOG4CPP_CATEGORY_HH
12 
13 #include <log4cpp/Portability.hh>
14 #include <log4cpp/Appender.hh>
15 #include <log4cpp/LoggingEvent.hh>
16 #include <log4cpp/Priority.hh>
19 #include <log4cpp/convenience.h>
20 
21 #include <map>
22 #include <vector>
23 #include <cstdarg>
24 #include <stdexcept>
25 
26 namespace log4cpp {
27 
34  friend class HierarchyMaintainer;
35 
36  public:
48  static Category& getRoot();
49 
54  static void setRootPriority(Priority::Value priority);
55 
60  static Priority::Value getRootPriority() throw();
61 
69  static Category& getInstance(const std::string& name);
70 
76  static Category* exists(const std::string& name);
77 
90  static std::vector<Category*>* getCurrentCategories();
91 
95  static void shutdown();
96 
100  virtual ~Category();
101 
106  virtual const std::string& getName() const throw();
107 
115  virtual void setPriority(Priority::Value priority)
116  throw(std::invalid_argument);
117 
122  virtual Priority::Value getPriority() const throw();
123 
132  virtual Priority::Value getChainedPriority() const throw();
133 
140  virtual bool isPriorityEnabled(Priority::Value priority) const throw();
141 
149  virtual void addAppender(Appender* appender)
150  throw(std::invalid_argument);
151 
158  virtual void addAppender(Appender& appender);
159 
168  inline void setAppender(Appender* appender) {
169  if (appender) {
170  addAppender(appender);
171  } else {
172  removeAllAppenders();
173  }
174  };
175 
182  inline void setAppender(Appender& appender) {
183  addAppender(appender);
184  };
185 
192  virtual Appender* getAppender() const;
193 
200  virtual Appender* getAppender(const std::string& name) const;
201 
207  virtual AppenderSet getAllAppenders() const;
208 
212  virtual void removeAllAppenders();
213 
218  virtual void removeAppender(Appender* appender);
219 
226  virtual bool ownsAppender() const throw() {
227  return ownsAppender(getAppender());
228  };
229 
235  virtual bool ownsAppender(Appender* appender) const throw();
236 
248  virtual void callAppenders(const LoggingEvent& event) throw();
249 
253  virtual void setAdditivity(bool additivity);
254 
258  virtual bool getAdditivity() const throw();
259 
265  virtual Category* getParent() throw();
266 
272  virtual const Category* getParent() const throw();
273 
281  virtual void log(Priority::Value priority, const char* stringFormat,
282  ...) throw();
283 
289  virtual void log(Priority::Value priority,
290  const std::string& message) throw();
291 
300  virtual void logva(Priority::Value priority,
301  const char* stringFormat,
302  va_list va) throw();
303 
310  void debug(const char* stringFormat, ...) throw();
311 
316  void debug(const std::string& message) throw();
317 
322  inline bool isDebugEnabled() const throw() {
323  return isPriorityEnabled(Priority::DEBUG);
324  };
325 
331  return getStream(Priority::DEBUG);
332  }
333 
340  void info(const char* stringFormat, ...) throw();
341 
346  void info(const std::string& message) throw();
347 
352  inline bool isInfoEnabled() const throw() {
353  return isPriorityEnabled(Priority::INFO);
354  };
355 
361  return getStream(Priority::INFO);
362  }
363 
370  void notice(const char* stringFormat, ...) throw();
371 
376  void notice(const std::string& message) throw();
377 
382  inline bool isNoticeEnabled() const throw() {
383  return isPriorityEnabled(Priority::NOTICE);
384  };
385 
391  return getStream(Priority::NOTICE);
392  }
393 
400  void warn(const char* stringFormat, ...) throw();
401 
406  void warn(const std::string& message) throw();
407 
412  inline bool isWarnEnabled() const throw() {
413  return isPriorityEnabled(Priority::WARN);
414  };
415 
421  return getStream(Priority::WARN);
422  };
423 
430  void error(const char* stringFormat, ...) throw();
431 
436  void error(const std::string& message) throw();
437 
442  inline bool isErrorEnabled() const throw() {
443  return isPriorityEnabled(Priority::ERROR);
444  };
445 
451  return getStream(Priority::ERROR);
452  };
453 
460  void crit(const char* stringFormat, ...) throw();
461 
466  void crit(const std::string& message) throw();
467 
472  inline bool isCritEnabled() const throw() {
473  return isPriorityEnabled(Priority::CRIT);
474  };
475 
481  return getStream(Priority::CRIT);
482  };
483 
490  void alert(const char* stringFormat, ...) throw();
491 
496  void alert(const std::string& message) throw();
497 
502  inline bool isAlertEnabled() const throw() {
503  return isPriorityEnabled(Priority::ALERT);
504  };
505 
510  inline CategoryStream alertStream() throw() {
511  return getStream(Priority::ALERT);
512  };
513 
520  void emerg(const char* stringFormat, ...) throw();
521 
526  void emerg(const std::string& message) throw();
527 
532  inline bool isEmergEnabled() const throw() {
533  return isPriorityEnabled(Priority::EMERG);
534  };
535 
541  return getStream(Priority::EMERG);
542  };
543 
552  void fatal(const char* stringFormat, ...) throw();
553 
560  void fatal(const std::string& message) throw();
561 
568  inline bool isFatalEnabled() const throw() {
569  return isPriorityEnabled(Priority::FATAL);
570  };
571 
579  return getStream(Priority::FATAL);
580  };
581 
587  virtual CategoryStream getStream(Priority::Value priority);
588 
594  virtual CategoryStream operator<<(Priority::Value priority);
595 
596  protected:
597 
606  Category(const std::string& name, Category* parent,
607  Priority::Value priority = Priority::NOTSET);
608 
609  virtual void _logUnconditionally(Priority::Value priority,
610  const char* format,
611  va_list arguments) throw();
612 
618  virtual void _logUnconditionally2(Priority::Value priority,
619  const std::string& message) throw();
620 
621  private:
622 
623  /* prevent copying and assignment */
624  Category(const Category& other);
625  Category& operator=(const Category& other);
626 
628  const std::string _name;
629 
635 
640 
641  typedef std::map<Appender *, bool> OwnsAppenderMap;
642 
649  virtual bool ownsAppender(Appender* appender,
650  OwnsAppenderMap::iterator& i2) throw();
651 
654 
660  OwnsAppenderMap _ownsAppender;
661 
666  volatile bool _isAdditive;
667 
668  };
669 
670 }
671 #endif // _LOG4CPP_CATEGORY_HH
bool isEmergEnabled() const
Definition: Category.hh:532
CategoryStream warnStream()
Definition: Category.hh:420
CategoryStream debugStream()
Definition: Category.hh:330
bool isDebugEnabled() const
Definition: Category.hh:322
OwnsAppenderMap _ownsAppender
Definition: Category.hh:660
ostream & operator<<(ostream &os, const width &w)
Definition: Manipulator.cpp:10
Category * _parent
Definition: Category.hh:634
const std::string _name
Definition: Category.hh:628
bool isWarnEnabled() const
Definition: Category.hh:412
CategoryStream infoStream()
Definition: Category.hh:360
AppenderSet _appender
Definition: Category.hh:652
virtual bool ownsAppender() const
Definition: Category.hh:226
bool isNoticeEnabled() const
Definition: Category.hh:382
bool isErrorEnabled() const
Definition: Category.hh:442
void setAppender(Appender &appender)
Definition: Category.hh:182
bool exists(const char *filename)
threading::Mutex _appenderSetMutex
Definition: Category.hh:653
CategoryStream fatalStream()
Definition: Category.hh:578
#define LOG4CPP_EXPORT
Definition: Export.hh:26
volatile bool _isAdditive
Definition: Category.hh:666
std::set< Appender * > AppenderSet
Definition: Appender.hh:147
CategoryStream critStream()
Definition: Category.hh:480
CategoryStream errorStream()
Definition: Category.hh:450
CategoryStream noticeStream()
Definition: Category.hh:390
std::map< Appender *, bool > OwnsAppenderMap
Definition: Category.hh:641
class LOG4CPP_EXPORT Category
CategoryStream alertStream()
Definition: Category.hh:510
volatile Priority::Value _priority
Definition: Category.hh:639
bool isInfoEnabled() const
Definition: Category.hh:352
bool isCritEnabled() const
Definition: Category.hh:472
bool isFatalEnabled() const
Definition: Category.hh:568
bool isAlertEnabled() const
Definition: Category.hh:502
CategoryStream emergStream()
Definition: Category.hh:540


log4cpp
Author(s): Stephen Roderick, Bastiaan Bakker, Cedric Le Goater, Steve Ostlind, Marcel Harkema, Walter Stroebel, Glenn Scott and Tony Cheung
autogenerated on Sun Jun 23 2019 19:14:17