nullappender.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /******************************************************************************
  2. *
  3. * package: Log4Qt
  4. * file: nullappender.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_NULLAPPENDER_H
  25. #define LOG4QT_NULLAPPENDER_H
  26. /******************************************************************************
  27. * Dependencies
  28. ******************************************************************************/
  29. #include "log4qt/appenderskeleton.h"
  30. /******************************************************************************
  31. * Declarations
  32. ******************************************************************************/
  33. namespace Log4Qt
  34. {
  35. /*!
  36. * \brief The class NullAppender ignores all requests to append.
  37. *
  38. * \note All the functions declared in this class are thread-safe.
  39. *
  40. * \note The ownership and lifetime of objects of this class are managed. See
  41. * \ref Ownership "Object ownership" for more details.
  42. */
  43. class NullAppender : public AppenderSkeleton
  44. {
  45. Q_OBJECT
  46. public:
  47. NullAppender(QObject *pParent = 0);
  48. virtual ~NullAppender();
  49. private:
  50. NullAppender(const NullAppender &rOther); // Not implemented
  51. NullAppender &operator=(const NullAppender &rOther); // Not implemented
  52. public:
  53. virtual bool requiresLayout() const;
  54. protected:
  55. virtual void append(const LoggingEvent &rEvent);
  56. #ifndef QT_NO_DEBUG_STREAM
  57. /*!
  58. * Writes all object member variables to the given debug stream \a rDebug and
  59. * returns the stream.
  60. *
  61. * <tt>
  62. * %NullAppender()
  63. * </tt>
  64. * \sa QDebug, operator<<(QDebug debug, const LogObject &rLogObject)
  65. */
  66. virtual QDebug debug(QDebug &rDebug) const;
  67. #endif // QT_NO_DEBUG_STREAM
  68. };
  69. /******************************************************************************
  70. * Operators, Helper
  71. ******************************************************************************/
  72. /******************************************************************************
  73. * Inline
  74. ******************************************************************************/
  75. inline bool NullAppender::requiresLayout() const
  76. { return false; }
  77. } // namespace Log4Qt
  78. // Q_DECLARE_TYPEINFO(Log4Qt::NullAppender, Q_COMPLEX_TYPE); // Use default
  79. #endif // LOG4QT_NULLAPPENDER_H