RollingFileAppender.hh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * RollingFileAppender.hh
  3. *
  4. * See the COPYING file for the terms of usage and distribution.
  5. */
  6. #ifndef _LOG4CPP_ROLLINGFILEAPPENDER_HH
  7. #define _LOG4CPP_ROLLINGFILEAPPENDER_HH
  8. #include <log4cpp/Portability.hh>
  9. #include <log4cpp/FileAppender.hh>
  10. #include <string>
  11. #include <stdarg.h>
  12. LOG4CPP_NS_BEGIN
  13. /**
  14. RollingFileAppender is a FileAppender that rolls over the logfile once
  15. it has reached a certain size limit.
  16. @since 0.3.1
  17. **/
  18. class LOG4CPP_EXPORT RollingFileAppender : public FileAppender {
  19. public:
  20. RollingFileAppender(const std::string& name,
  21. const std::string& fileName,
  22. size_t maxFileSize = 10 * 1024 * 1024,
  23. unsigned int maxBackupIndex = 1,
  24. bool append = true,
  25. mode_t mode = 00644);
  26. virtual void setMaxBackupIndex(unsigned int maxBackups);
  27. virtual unsigned int getMaxBackupIndex() const;
  28. virtual void setMaximumFileSize(size_t maxFileSize);
  29. virtual size_t getMaxFileSize() const;
  30. virtual void rollOver();
  31. protected:
  32. virtual void _append(const LoggingEvent& event);
  33. unsigned int _maxBackupIndex;
  34. unsigned short int _maxBackupIndexWidth; // keep constant index width by zeroing leading positions
  35. size_t _maxFileSize;
  36. private:
  37. // suppress assignment operator
  38. RollingFileAppender & operator=(const RollingFileAppender &);
  39. };
  40. LOG4CPP_NS_END
  41. #endif // _LOG4CPP_ROLLINGFILEAPPENDER_HH