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 "Base/GCException.h"
14 #include <log4cpp/Portability.hh>
15 #include <log4cpp/Appender.hh>
16 #include <log4cpp/LoggingEvent.hh>
17 #include <log4cpp/Priority.hh>
20 #include <log4cpp/convenience.h>
21 
22 #include <map>
23 #include <vector>
24 #include <cstdarg>
25 #include <stdexcept>
26 
28 
35  friend class HierarchyMaintainer;
36 
37  public:
49  static Category& getRoot();
50 
55  static void setRootPriority(Priority::Value priority);
56 
61  static Priority::Value getRootPriority() throw();
62 
70  static Category& getInstance(const std::string& name);
71 
77  static Category* exists(const std::string& name);
78 
91  static std::vector<Category*>* getCurrentCategories();
92 
96  static void shutdown();
97 
101  virtual ~Category();
102 
107  virtual const std::string& getName() const throw();
108 
116  virtual void setPriority(Priority::Value priority);
117  //throw(GenICam::InvalidArgumentException);
118 
123  virtual Priority::Value getPriority() const throw();
124 
133  virtual Priority::Value getChainedPriority() const throw();
134 
141  virtual bool isPriorityEnabled(Priority::Value priority) const throw();
142 
150  virtual void addAppender(Appender* appender);
151  //throw(GenICam::InvalidArgumentException);
152 
159  virtual void addAppender(Appender& appender);
160 
169  inline void setAppender(Appender* appender) {
170  if (appender) {
171  addAppender(appender);
172  } else {
173  removeAllAppenders();
174  }
175  };
176 
183  inline void setAppender(Appender& appender) {
184  addAppender(appender);
185  };
186 
193  virtual Appender* getAppender() const;
194 
201  virtual Appender* getAppender(const std::string& name) const;
202 
208  virtual AppenderSet getAllAppenders() const;
209 
213  virtual void removeAllAppenders();
214 
219  virtual void removeAppender(Appender* appender);
220 
227  virtual bool ownsAppender() const throw() {
228  return ownsAppender(getAppender());
229  };
230 
236  virtual bool ownsAppender(Appender* appender) const throw();
237 
249  virtual void callAppenders(const LoggingEvent& event) throw();
250 
254  virtual void setAdditivity(bool additivity);
255 
259  virtual bool getAdditivity() const throw();
260 
266  virtual Category* getParent() throw();
267 
273  virtual const Category* getParent() const throw();
274 
282  virtual void log(Priority::Value priority, const char* stringFormat,
283  ...) throw();
284 
290  virtual void log(Priority::Value priority,
291  const std::string& message) throw();
292 
301  virtual void logva(Priority::Value priority,
302  const char* stringFormat,
303  va_list va) throw();
304 
311  void debug(const char* stringFormat, ...) throw();
312 
317  void debug(const std::string& message) throw();
318 
323  inline bool isDebugEnabled() throw() {
324  if( !_ValidDebugEnabledCache )
325  {
326  _DebugEnabled = isPriorityEnabled(Priority::DEBUG);
327  _ValidDebugEnabledCache = true;
328  }
329  return _DebugEnabled;
330  };
331 
337  return getStream(Priority::DEBUG);
338  }
339 
346  void info(const char* stringFormat, ...) throw();
347 
354  void info_push(const char* stringFormat, ...) throw();
355 
362  void info_pop(const char* stringFormat, ...) throw();
363 
368  void info(const std::string& message) throw();
369 
374  inline bool isInfoEnabled() throw() {
375  if( !_ValidInfoEnabledCache )
376  {
377  _InfoEnabled = isPriorityEnabled(Priority::INFO);
378  _ValidInfoEnabledCache = true;
379  }
380  return _InfoEnabled;
381  };
382 
388  return getStream(Priority::INFO);
389  }
390 
397  void notice(const char* stringFormat, ...) throw();
398 
403  void notice(const std::string& message) throw();
404 
409  inline bool isNoticeEnabled() const throw() {
410  return isPriorityEnabled(Priority::NOTICE);
411  };
412 
418  return getStream(Priority::NOTICE);
419  }
420 
427  void warn(const char* stringFormat, ...) throw();
428 
433  void warn(const std::string& message) throw();
434 
439  inline bool isWarnEnabled() throw() {
440  if( !_ValidWarnEnabledCache )
441  {
442  _WarnEnabled = isPriorityEnabled(Priority::WARN);
443  _ValidWarnEnabledCache = true;
444  }
445  return _WarnEnabled;
446  };
447 
453  return getStream(Priority::WARN);
454  };
455 
462  void error(const char* stringFormat, ...) throw();
463 
468  void error(const std::string& message) throw();
469 
474  inline bool isErrorEnabled() const throw() {
475  return isPriorityEnabled(Priority::ERROR);
476  };
477 
483  return getStream(Priority::ERROR);
484  };
485 
492  void crit(const char* stringFormat, ...) throw();
493 
498  void crit(const std::string& message) throw();
499 
504  inline bool isCritEnabled() const throw() {
505  return isPriorityEnabled(Priority::CRIT);
506  };
507 
513  return getStream(Priority::CRIT);
514  };
515 
522  void alert(const char* stringFormat, ...) throw();
523 
528  void alert(const std::string& message) throw();
529 
534  inline bool isAlertEnabled() const throw() {
535  return isPriorityEnabled(Priority::ALERT);
536  };
537 
542  inline CategoryStream alertStream() throw() {
543  return getStream(Priority::ALERT);
544  };
545 
552  void emerg(const char* stringFormat, ...) throw();
553 
558  void emerg(const std::string& message) throw();
559 
564  inline bool isEmergEnabled() const throw() {
565  return isPriorityEnabled(Priority::EMERG);
566  };
567 
573  return getStream(Priority::EMERG);
574  };
575 
584  void fatal(const char* stringFormat, ...) throw();
585 
592  void fatal(const std::string& message) throw();
593 
600  inline bool isFatalEnabled() const throw() {
601  return isPriorityEnabled(Priority::FATAL);
602  };
603 
611  return getStream(Priority::FATAL);
612  };
613 
619  virtual CategoryStream getStream(Priority::Value priority);
620 
626  virtual CategoryStream operator<<(Priority::Value priority);
627 
628  protected:
629 
638  Category(const std::string& name, Category* parent,
639  Priority::Value priority = Priority::NOTSET);
640 
641  virtual void _logUnconditionally(Priority::Value priority,
642  const char* format,
643  va_list arguments) throw();
644 
650  virtual void _logUnconditionally2(Priority::Value priority,
651  const std::string& message) throw();
652 
653  private:
654 
655  /* prevent copying and assignment */
656  Category(const Category& other);
657  Category& operator=(const Category& other);
658 
660  const std::string _name;
661 
667 
672 
673  typedef std::map<Appender *, bool> OwnsAppenderMap;
674 
681  virtual bool ownsAppender(Appender* appender,
682  OwnsAppenderMap::iterator& i2) throw();
683 
686 
692  OwnsAppenderMap _ownsAppender;
693 
698  volatile bool _isAdditive;
699 
702 
705 
708 
711 
714 
717 
719  void InvalidateEnabledCache(bool InvalidateAll = true);
720  };
721 
723 #endif // _LOG4CPP_CATEGORY_HH
#define LOG4CPP_NS_END
Definition: Portability.hh:50
bool isNoticeEnabled() const
Return true if the Category will log messages with priority NOTICE.
Definition: Category.hh:409
CategoryStream critStream()
Return a CategoryStream with priority CRIT.
Definition: Category.hh:512
HierarchyMaintainer is an internal log4cpp class.
CategoryStream errorStream()
Return a CategoryStream with priority ERROR.
Definition: Category.hh:482
Category * _parent
The parent of this category.
Definition: Category.hh:666
bool _DebugEnabled
Indicates that logging is enabled for Info level.
Definition: Category.hh:710
bool _ValidWarnEnabledCache
Indicates if the *Enabled flags are valid.
Definition: Category.hh:713
CategoryStream debugStream()
Return a CategoryStream with priority DEBUG.
Definition: Category.hh:336
CategoryStream emergStream()
Return a CategoryStream with priority EMERG.
Definition: Category.hh:572
bool isWarnEnabled()
Return true if the Category will log messages with priority WARN.
Definition: Category.hh:439
threading::Mutex _appenderSetMutex
Definition: Category.hh:685
bool isErrorEnabled() const
Return true if the Category will log messages with priority ERROR.
Definition: Category.hh:474
bool _ValidInfoEnabledCache
Indicates if the *Enabled flags are valid.
Definition: Category.hh:701
bool isInfoEnabled()
Return true if the Category will log messages with priority INFO.
Definition: Category.hh:374
CategoryStream infoStream()
Return a CategoryStream with priority INFO.
Definition: Category.hh:387
virtual void operator=(bool Value)
Set node value.
Definition: IBoolean.h:64
The top level namespace for all &#39;Log for C++&#39; types and classes.
Definition: LoggingEvent.hh:32
bool _ValidDebugEnabledCache
Indicates if the *Enabled flags are valid.
Definition: Category.hh:707
volatile Priority::Value _priority
The assigned priority of this category.
Definition: Category.hh:671
LOG4CPP_NS_BEGIN class LOG4CPP_EXPORT Category
volatile bool _isAdditive
Additivity is set to true by default, i.e.
Definition: Category.hh:698
virtual Category & getInstance(const std::string &name)
AppenderSet _appender
Definition: Category.hh:684
The Priority class provides importance levels with which one can categorize log messages.
Definition: Priority.hh:62
const std::string _name
The name of this category.
Definition: Category.hh:660
std::ostream & operator<<(std::ostream &ostr, const GENICAM_NAMESPACE::gcstring &str)
STL operator out.
Definition: GCString.h:225
bool _InfoEnabled
Indicates that logging is enabled for Info level.
Definition: Category.hh:704
OwnsAppenderMap _ownsAppender
Whether the category holds the ownership of the appender.
Definition: Category.hh:692
#define LOG4CPP_EXPORT
Definition: Export.hh:21
This is the central class in the log4j package.
Definition: Category.hh:34
CategoryStream fatalStream()
Return a CategoryStream with priority FATAL.
Definition: Category.hh:610
void setAppender(Appender &appender)
Adds an Appender for this Category.
Definition: Category.hh:183
bool isDebugEnabled()
Return true if the Category will log messages with priority DEBUG.
Definition: Category.hh:323
CategoryStream noticeStream()
Return a CategoryStream with priority NOTICE.
Definition: Category.hh:417
CategoryStream alertStream()
Return a CategoryStream with priority ALERT.
Definition: Category.hh:542
std::set< Appender * > AppenderSet
Definition: Appender.hh:153
virtual void shutdown()
std::map< Appender *, bool > OwnsAppenderMap
Definition: Category.hh:673
bool isFatalEnabled() const
Return true if the Category will log messages with priority FATAL.
Definition: Category.hh:600
bool isAlertEnabled() const
Return true if the Category will log messages with priority ALERT.
Definition: Category.hh:534
This class enables streaming simple types and objects to a category.
CategoryStream warnStream()
Return a CategoryStream with priority WARN.
Definition: Category.hh:452
virtual bool ownsAppender() const
Returns true if the Category owns the first Appender in its Appender set.
Definition: Category.hh:227
bool isCritEnabled() const
Return true if the Category will log messages with priority CRIT.
Definition: Category.hh:504
int Value
The type of Priority Values.
Definition: Priority.hh:87
Implement this interface for your own strategies for printing log statements.
Definition: Appender.hh:33
bool _WarnEnabled
Indicates that logging is enabled for Info level.
Definition: Category.hh:716
bool isEmergEnabled() const
Return true if the Category will log messages with priority EMERG.
Definition: Category.hh:564
virtual std::vector< Category * > * getCurrentCategories() const
#define LOG4CPP_NS_BEGIN
Definition: Portability.hh:49


rc_genicam_api
Author(s): Heiko Hirschmueller
autogenerated on Wed Mar 17 2021 02:48:40