You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.4 KiB

  1. // -*- C++ -*-
  2. // Module: Log4CPLUS
  3. // File: nteventlogappender.h
  4. // Created: 4/2003
  5. // Author: Michael CATANZARITI
  6. //
  7. // Copyright 2003-2010 Michael CATANZARITI
  8. //
  9. // Licensed under the Apache License, Version 2.0 (the "License");
  10. // you may not use this file except in compliance with the License.
  11. // You may obtain a copy of the License at
  12. //
  13. // http://www.apache.org/licenses/LICENSE-2.0
  14. //
  15. // Unless required by applicable law or agreed to in writing, software
  16. // distributed under the License is distributed on an "AS IS" BASIS,
  17. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18. // See the License for the specific language governing permissions and
  19. // limitations under the License.
  20. /** @file */
  21. #ifndef LOG4CPLUS_NT_EVENT_LOG_APPENDER_HEADER_
  22. #define LOG4CPLUS_NT_EVENT_LOG_APPENDER_HEADER_
  23. #include <log4cplus/config.hxx>
  24. #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
  25. #pragma once
  26. #endif
  27. #if defined (LOG4CPLUS_HAVE_NT_EVENT_LOG)
  28. #include <log4cplus/appender.h>
  29. #include <log4cplus/config/windowsh-inc.h>
  30. namespace log4cplus {
  31. /**
  32. * Appends log events to NT EventLog.
  33. */
  34. class LOG4CPLUS_EXPORT NTEventLogAppender : public Appender {
  35. public:
  36. // ctors
  37. NTEventLogAppender(const log4cplus::tstring& server,
  38. const log4cplus::tstring& log,
  39. const log4cplus::tstring& source);
  40. NTEventLogAppender(const log4cplus::helpers::Properties & properties);
  41. // dtor
  42. virtual ~NTEventLogAppender();
  43. // public Methods
  44. virtual void close();
  45. protected:
  46. virtual void append(const spi::InternalLoggingEvent& event);
  47. virtual WORD getEventType(const spi::InternalLoggingEvent& event);
  48. virtual WORD getEventCategory(const spi::InternalLoggingEvent& event);
  49. void init();
  50. /*
  51. * Add this source with appropriate configuration keys to the registry.
  52. */
  53. void addRegistryInfo();
  54. // Data
  55. log4cplus::tstring server;
  56. log4cplus::tstring log;
  57. log4cplus::tstring source;
  58. HANDLE hEventLog;
  59. SID* pCurrentUserSID;
  60. private:
  61. // Disallow copying of instances of this class
  62. NTEventLogAppender(const NTEventLogAppender&);
  63. NTEventLogAppender& operator=(const NTEventLogAppender&);
  64. };
  65. } // end namespace log4cplus
  66. #endif // LOG4CPLUS_HAVE_NT_EVENT_LOG
  67. #endif //LOG4CPLUS_NT_EVENT_LOG_APPENDER_HEADER_