ECArchiverLogger.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright 2005 - 2016 Zarafa and its licensors
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU Affero General Public License, version 3,
  6. * as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU Affero General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Affero General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. *
  16. */
  17. #ifndef LOGGER_H
  18. #define LOGGER_H
  19. #include <kopano/zcdefs.h>
  20. #include <kopano/ECLogger.h>
  21. namespace KC {
  22. class _kc_export ECArchiverLogger _kc_final : public ECLogger {
  23. public:
  24. ECArchiverLogger(ECLogger *lpLogger);
  25. _kc_hidden ~ECArchiverLogger(void);
  26. _kc_hidden tstring SetUser(tstring = tstring());
  27. tstring SetFolder(tstring strFolder = tstring());
  28. _kc_hidden const tstring &GetUser(void) const { return m_strUser; }
  29. _kc_hidden const tstring &GetFolder(void) const { return m_strFolder; }
  30. _kc_hidden void Reset(void);
  31. _kc_hidden void Log(unsigned int level, const std::string &msg);
  32. void Log(unsigned int level, const char *fmt, ...) __LIKE_PRINTF(3, 4);
  33. _kc_hidden void LogVA(unsigned int level, const char *fmt, va_list &);
  34. private:
  35. _kc_hidden std::string CreateFormat(const char *fmt);
  36. _kc_hidden std::string EscapeFormatString(const std::string &fmt);
  37. ECArchiverLogger(const ECArchiverLogger &) = delete;
  38. ECArchiverLogger &operator=(const ECArchiverLogger &) = delete;
  39. ECLogger *m_lpLogger;
  40. tstring m_strUser;
  41. tstring m_strFolder;
  42. };
  43. class _kc_export ScopedUserLogging _kc_final {
  44. public:
  45. ScopedUserLogging(ECArchiverLogger *lpLogger, const tstring &strUser);
  46. ~ScopedUserLogging();
  47. private:
  48. ScopedUserLogging(const ScopedUserLogging &) = delete;
  49. ScopedUserLogging &operator=(const ScopedUserLogging &) = delete;
  50. ECArchiverLogger *m_lpLogger;
  51. const tstring m_strPrevUser;
  52. };
  53. class _kc_export ScopedFolderLogging _kc_final {
  54. public:
  55. ScopedFolderLogging(ECArchiverLogger *lpLogger, const tstring &strFolder);
  56. ~ScopedFolderLogging();
  57. private:
  58. ScopedFolderLogging(const ScopedFolderLogging &) = delete;
  59. ScopedFolderLogging &operator=(const ScopedFolderLogging &) = delete;
  60. ECArchiverLogger *m_lpLogger;
  61. const tstring m_strPrevFolder;
  62. };
  63. } /* namespace */
  64. #endif // ndef LOGGER_H