appender.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /******************************************************************************
  2. *
  3. * package: Log4Qt
  4. * file: appender.h
  5. * created: September 2007
  6. * author: Martin Heinrich
  7. *
  8. *
  9. * Copyright 2007 Martin Heinrich
  10. *
  11. * Licensed under the Apache License, Version 2.0 (the "License");
  12. * you may not use this file except in compliance with the License.
  13. * You may obtain a copy of the License at
  14. *
  15. * http://www.apache.org/licenses/LICENSE-2.0
  16. *
  17. * Unless required by applicable law or agreed to in writing, software
  18. * distributed under the License is distributed on an "AS IS" BASIS,
  19. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  20. * See the License for the specific language governing permissions and
  21. * limitations under the License.
  22. *
  23. ********************************************************************************/
  24. #ifndef LOG4QT_APPENDER_H
  25. #define LOG4QT_APPENDER_H
  26. /******************************************************************************
  27. * Dependencies
  28. ******************************************************************************/
  29. #include "log4qt/helpers/logobject.h"
  30. #include "log4qt/helpers/logobjectptr.h"
  31. #include "log4qt/logger.h"
  32. /******************************************************************************
  33. * Declarations
  34. ******************************************************************************/
  35. namespace Log4Qt
  36. {
  37. class Filter;
  38. class Layout;
  39. class LoggingEvent;
  40. /*!
  41. * \brief The class Appender is the base class for all Appenders.
  42. *
  43. * To allow the whole hirarchy to be an ascendant of QObject Appender is
  44. * not an interface.
  45. *
  46. * \note All the functions declared in this class are thread-safe.
  47. *
  48. * \note The ownership and lifetime of objects of this class are managed.
  49. * See \ref Ownership "Object ownership" for more details.
  50. */
  51. class Appender : public LogObject
  52. {
  53. Q_OBJECT
  54. /*!
  55. * The property holds the Layout used by the Appender.
  56. *
  57. * \sa layout(), setLayout()
  58. */
  59. Q_PROPERTY(Layout* layout READ layout WRITE setLayout)
  60. /*!
  61. * The property holds the name of the Appender.
  62. *
  63. * \sa name(), setName()
  64. */
  65. Q_PROPERTY(QString name READ name WRITE setName)
  66. /*!
  67. * The property holds if the Appender requires a Layout or not.
  68. *
  69. * \sa requiresLayout(), setRequiresLayout()
  70. */
  71. Q_PROPERTY(bool requiresLayout READ requiresLayout)
  72. public:
  73. Appender(QObject *pParent = 0);
  74. virtual ~Appender();
  75. private:
  76. Appender(const Appender &rOther); // Not implemented
  77. Appender &operator=(const Appender &rOther); // Not implemented
  78. public:
  79. // JAVA: ErrorHandler* errorHandler();
  80. virtual Filter *filter() const = 0;
  81. virtual QString name() const = 0;
  82. virtual Layout *layout() const = 0;
  83. virtual bool requiresLayout() const = 0;
  84. // JAVA: void setErrorHandler(ErrorHandler *pErrorHandler);
  85. virtual void setLayout(Layout *pLayout) = 0;
  86. virtual void setName(const QString &rName) = 0;
  87. virtual void addFilter(Filter *pFilter) = 0;
  88. virtual void clearFilters() = 0;
  89. virtual void close() = 0;
  90. virtual void doAppend(const LoggingEvent &rEvent) = 0;
  91. };
  92. /**************************************************************************
  93. * Operators, Helper
  94. **************************************************************************/
  95. /**************************************************************************
  96. * Inline
  97. **************************************************************************/
  98. inline Appender::Appender(QObject *pParent) :
  99. LogObject(pParent)
  100. {}
  101. inline Appender::~Appender()
  102. {}
  103. } // namespace Log4Qt
  104. // Q_DECLARE_TYPEINFO(Log4Qt::Appender, Q_COMPLEX_TYPE); // Use default
  105. Q_DECLARE_TYPEINFO(Log4Qt::LogObjectPtr<Log4Qt::Appender>, Q_MOVABLE_TYPE);
  106. #endif // LOG4QT_APPENDER_H