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 
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
LoggingEvent
The top level namespace for all 'Log for C++' types and classes.
Definition: LoggingEvent.hh:32
Priority.hh
Category::emergStream
CategoryStream emergStream()
Return a CategoryStream with priority EMERG.
Definition: Category.hh:572
Category::_ValidDebugEnabledCache
bool _ValidDebugEnabledCache
Indicates if the *Enabled flags are valid.
Definition: Category.hh:707
Priority::CRIT
@ CRIT
Definition: Priority.hh:75
threading::Mutex
Definition: PThreads.hh:58
Portability.hh
Category::OwnsAppenderMap
std::map< Appender *, bool > OwnsAppenderMap
Definition: Category.hh:673
Category
This is the central class in the log4j package.
Definition: Category.hh:34
HierarchyMaintainer::getCurrentCategories
virtual std::vector< Category * > * getCurrentCategories() const
Category::noticeStream
CategoryStream noticeStream()
Return a CategoryStream with priority NOTICE.
Definition: Category.hh:417
Priority::ALERT
@ ALERT
Definition: Priority.hh:74
Priority::Value
int Value
The type of Priority Values.
Definition: Priority.hh:87
Category::fatalStream
CategoryStream fatalStream()
Return a CategoryStream with priority FATAL.
Definition: Category.hh:610
HierarchyMaintainer::getInstance
virtual Category & getInstance(const std::string &name)
HierarchyMaintainer
HierarchyMaintainer is an internal log4cpp class.
Definition: HierarchyMaintainer.hh:27
Priority::DEBUG
@ DEBUG
Definition: Priority.hh:80
CategoryStream
This class enables streaming simple types and objects to a category.
Definition: CategoryStream.hh:39
Category::alertStream
CategoryStream alertStream()
Return a CategoryStream with priority ALERT.
Definition: Category.hh:542
Category::_ValidWarnEnabledCache
bool _ValidWarnEnabledCache
Indicates if the *Enabled flags are valid.
Definition: Category.hh:713
Category::_DebugEnabled
bool _DebugEnabled
Indicates that logging is enabled for Info level.
Definition: Category.hh:710
Priority::NOTSET
@ NOTSET
Definition: Priority.hh:81
Category
LOG4CPP_NS_BEGIN class LOG4CPP_EXPORT Category
Definition: CategoryStream.hh:23
Threading.hh
AppenderSet
std::set< Appender * > AppenderSet
Definition: Appender.hh:153
Category::debugStream
CategoryStream debugStream()
Return a CategoryStream with priority DEBUG.
Definition: Category.hh:336
Priority::INFO
@ INFO
Definition: Priority.hh:79
Appender
Implement this interface for your own strategies for printing log statements.
Definition: Appender.hh:33
operator<<
std::ostream & operator<<(std::ostream &ostr, const GENICAM_NAMESPACE::gcstring &str)
STL operator out.
Definition: GCString.h:231
LOG4CPP_NS_BEGIN
#define LOG4CPP_NS_BEGIN
Definition: Portability.hh:49
Category::_ownsAppender
OwnsAppenderMap _ownsAppender
Whether the category holds the ownership of the appender.
Definition: Category.hh:692
LOG4CPP_NS_END
#define LOG4CPP_NS_END
Definition: Portability.hh:50
Category::_ValidInfoEnabledCache
bool _ValidInfoEnabledCache
Indicates if the *Enabled flags are valid.
Definition: Category.hh:701
Priority::NOTICE
@ NOTICE
Definition: Priority.hh:78
LOG4CPP_EXPORT
#define LOG4CPP_EXPORT
Definition: Export.hh:21
Appender.hh
LoggingEvent.hh
CategoryStream.hh
Category::_priority
volatile Priority::Value _priority
The assigned priority of this category.
Definition: Category.hh:671
Priority::EMERG
@ EMERG
Definition: Priority.hh:72
Category::setAppender
void setAppender(Appender &appender)
Adds an Appender for this Category.
Definition: Category.hh:183
Category::_appenderSetMutex
threading::Mutex _appenderSetMutex
Definition: Category.hh:685
HierarchyMaintainer::shutdown
virtual void shutdown()
std
Definition: Portability.hh:41
Category::_InfoEnabled
bool _InfoEnabled
Indicates that logging is enabled for Info level.
Definition: Category.hh:704
Priority::FATAL
@ FATAL
Definition: Priority.hh:73
Category::warnStream
CategoryStream warnStream()
Return a CategoryStream with priority WARN.
Definition: Category.hh:452
Category::critStream
CategoryStream critStream()
Return a CategoryStream with priority CRIT.
Definition: Category.hh:512
Category::ownsAppender
virtual bool ownsAppender() const
Returns true if the Category owns the first Appender in its Appender set.
Definition: Category.hh:227
convenience.h
GCException.h
Category::_parent
Category * _parent
The parent of this category.
Definition: Category.hh:666
GENAPI_NAMESPACE::operator=
virtual IBoolean & operator=(bool Value)
Set node value.
Definition: IBoolean.h:64
Category::_appender
AppenderSet _appender
Definition: Category.hh:684
Category::_isAdditive
volatile bool _isAdditive
Additivity is set to true by default, i.e.
Definition: Category.hh:698
Priority::WARN
@ WARN
Definition: Priority.hh:77
Priority
The Priority class provides importance levels with which one can categorize log messages.
Definition: Priority.hh:62
Category::_name
const std::string _name
The name of this category.
Definition: Category.hh:660
Priority::ERROR
@ ERROR
Definition: Priority.hh:76
Category::errorStream
CategoryStream errorStream()
Return a CategoryStream with priority ERROR.
Definition: Category.hh:482
Category::_WarnEnabled
bool _WarnEnabled
Indicates that logging is enabled for Info level.
Definition: Category.hh:716
Category::infoStream
CategoryStream infoStream()
Return a CategoryStream with priority INFO.
Definition: Category.hh:387


rc_genicam_api
Author(s): Heiko Hirschmueller
autogenerated on Wed Dec 4 2024 03:10:11