debugappender.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /******************************************************************************
  2. *
  3. * package: Log4Qt
  4. * file: debugappender.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_DEBUGAPPENDER_H
  25. #define LOG4QT_DEBUGAPPENDER_H
  26. /******************************************************************************
  27. * Dependencies
  28. ******************************************************************************/
  29. #include "log4qt/appenderskeleton.h"
  30. /******************************************************************************
  31. * Declarations
  32. ******************************************************************************/
  33. namespace Log4Qt
  34. {
  35. /*!
  36. * \brief The class DebugAppender appends logging events to the platform
  37. * specific debug output.
  38. *
  39. * A DebugAppender appends to the Debugger on Windows and to stderr on all
  40. * other systems.
  41. *
  42. * \note All the functions declared in this class are thread-safe.
  43. *
  44. * \note The ownership and lifetime of objects of this class are managed.
  45. * See \ref Ownership "Object ownership" for more details.
  46. */
  47. class DebugAppender : public AppenderSkeleton
  48. {
  49. Q_OBJECT
  50. public:
  51. /*!
  52. * Creates a DebugAppender.
  53. */
  54. DebugAppender(QObject *pParent = 0);
  55. /*!
  56. * Creates a DebugAppender with the specified layout \a pLayout
  57. */
  58. DebugAppender(Layout *pLayout,
  59. QObject *pParent = 0);
  60. // virtual ~DebugAppender(); // Use compiler default
  61. private:
  62. DebugAppender(const DebugAppender &rOther); // Not implemented
  63. DebugAppender &operator=(const DebugAppender &rOther); // Not implemented
  64. public:
  65. /*!
  66. * The DebugAppended requires a layout. The function returns true.
  67. *
  68. * \sa setLayout()
  69. */
  70. virtual bool requiresLayout() const;
  71. protected:
  72. /*!
  73. * Appends the specified logging event \a rEvent to the debug output.
  74. * The output is formatted using the appender's layout.
  75. *
  76. * The method is called by the AppenderSkeleton::doAppend() after it
  77. * the entry conditions have been tested and it has been found that the
  78. * logging event needs to be appended.
  79. *
  80. * \sa setLayout(), AppenderSkeleton::doAppend(), checkEntryConditions()
  81. */
  82. virtual void append(const LoggingEvent &rEvent);
  83. #ifndef QT_NO_DEBUG_STREAM
  84. /*!
  85. * Writes all object member variables to the given debug stream \a rDebug
  86. * and returns the stream.
  87. *
  88. * <tt>
  89. * %DebugAppender(name:"DA" filter:0x3bee6b8 isactive:true isclosed:false
  90. * layout:"SL" referencecount:1 threshold:"NULL")
  91. * </tt>
  92. * \sa QDebug, operator<<(QDebug debug, const LogObject &rLogObject)
  93. */
  94. virtual QDebug debug(QDebug &rDebug) const;
  95. #endif // QT_NO_DEBUG_STREAM
  96. };
  97. /**************************************************************************
  98. * Operators, Helper
  99. **************************************************************************/
  100. /**************************************************************************
  101. * Inline
  102. **************************************************************************/
  103. inline DebugAppender::DebugAppender(QObject *pParent) :
  104. AppenderSkeleton(pParent)
  105. {}
  106. } // namespace Log4Qt
  107. // Q_DECLARE_TYPEINFO(Log4Qt::DebugAppender, Q_COMPLEX_TYPE); // Use default
  108. #endif // LOG4QT_DEBUGAPPENDER_H