Wrapper.hh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #ifndef _LOG4CPP_WRAPPER_HH
  2. #define _LOG4CPP_WRAPPER_HH
  3. #include <log4cpp/Category.hh>
  4. #include <log4cpp/NDC.hh>
  5. #include <log4cpp/PatternLayout.hh>
  6. #include <log4cpp/PropertyConfigurator.hh>
  7. #if defined (_WIN32)
  8. #include <log4cpp/Win32DebugAppender.hh>
  9. #endif
  10. LOG4CPP_NS_BEGIN
  11. //! A function table which is bound to log4cpp's Category class
  12. typedef struct {
  13. Category& (*getInstance)(const std::string& name);
  14. std::vector<Category*>* (*getCurrentCategories)();
  15. Category* (*exists)(const std::string& name);
  16. Category& (*getRoot)();
  17. void(*shutdown)();
  18. void (Category::*logva)(Priority::Value priority, const char* stringFormat, va_list va);
  19. bool (Category::*isInfoEnabled)();
  20. bool (Category::*isWarnEnabled)();
  21. bool (Category::*isDebugEnabled)();
  22. void (Category::*setPriority)(Priority::Value priority);
  23. void (Category::*addAppender)(Appender* appender);
  24. void (Category::*removeAppender)(Appender* appender);
  25. } category_t;
  26. //! A function table which is bound to log4cpp's PatternLayout class
  27. typedef struct {
  28. PatternLayout* (*create)();
  29. void (PatternLayout::*setConversionPattern)(const std::string& conversionPattern);
  30. void(*destroy)(PatternLayout* object);
  31. } pattern_layout_t;
  32. //! A function table which is bound to log4cpp's PropertyConfigurator class
  33. typedef struct {
  34. void(*configure)(std::istream& initStream);
  35. } property_configurator_t;
  36. //! A function table which is bound to log4cpp's NDC class
  37. typedef struct {
  38. void(*push)(const std::string& message);
  39. std::string(*pop)();
  40. } ndc_t;
  41. #if defined (_WIN32)
  42. //! A function table which is bound to log4cpp's Win32DebugAppender class
  43. typedef struct {
  44. Appender *(*create)(const std::string& name);
  45. } win32_debug_appender_t;
  46. #endif
  47. //! A function table which is bound to log4cpp's Appender class
  48. typedef struct {
  49. Appender *(*createFileAppender)(const std::string& name, const std::string& fileName, bool append, mode_t mode);
  50. void (Appender::*setThreshold)(Priority::Value threshold);
  51. void (Appender::*setLayout)(Layout* layout);
  52. } appender_t;
  53. //! A wrapper which bridges to log4cpp functionality.
  54. typedef struct {
  55. category_t Category;
  56. pattern_layout_t PatternLayout;
  57. property_configurator_t PropertyConfigurator;
  58. ndc_t NDC;
  59. #if defined (_WIN32)
  60. win32_debug_appender_t Win32DebugAppender;
  61. #endif
  62. appender_t Appender;
  63. } wrapper_t;
  64. //! A functionality wrapper (= a set of function tables) which is exported.
  65. extern "C" LOG4CPP_EXPORT const LOG4CPP_NS::wrapper_t Wrapper;
  66. LOG4CPP_NS_END
  67. #endif // _LOG4CPP_WRAPPER_HH