jelogtype.hpp 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. /* This header file should never be #included directly.
  14. It is included three times:
  15. once in jlog.hpp (and so almost everywhere) with macros defined so that it declares the values for AuditType,
  16. once in jlog.cpp with macros defined so that it initiates the array of mappings for translation to win32 event log fields,
  17. and once in the ECL plugin with macros defined so that it initiates the array of mappings from ECL strings to AuditTypes.
  18. MAKE_AUDIT_TYPE(name, type, categoryid, eventid, level)
  19. where:
  20. AUDIT_TYPE_name is the value that will be declared for use in C++, and "name" is the value that will be used in ECL
  21. (n.b. names should be declared in upper case; ECL strings will be upcased before comparison and so are insensitive)
  22. type is the win32 event type, one of the values defined in WINNT.H, namely
  23. EVENTLOG_ERROR_TYPE, EVENTLOG_WARNING_TYPE, EVENTLOG_INFORMATION_TYPE, EVENTLOG_AUDIT_SUCCESS, EVENTLOG_AUDIT_FAILURE
  24. categoryid is the custom win32 category ID, see SCMSG_CATEGORY_* in jelog.h
  25. eventid is the custom win32 event ID, see MSG_JLOG_* in jelog.h
  26. level is the linux log level, see syslog man page, namely one of
  27. LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO, LOG_DEBUG
  28. */
  29. AUDIT_TYPES_BEGIN
  30. MAKE_AUDIT_TYPE(DEBUG, EVENTLOG_INFORMATION_TYPE, SCMSG_CATEGORY_DEBUG, MSG_JLOG_INFORMATIONAL, LOG_DEBUG)
  31. MAKE_AUDIT_TYPE(INFO, EVENTLOG_INFORMATION_TYPE, SCMSG_CATEGORY_AUDIT, MSG_JLOG_INFORMATIONAL, LOG_INFO)
  32. MAKE_AUDIT_TYPE(ERROR, EVENTLOG_INFORMATION_TYPE, SCMSG_CATEGORY_AUDIT, MSG_JLOG_ERROR, LOG_ERR)
  33. MAKE_AUDIT_TYPE(ACCESS_FAILURE, EVENTLOG_AUDIT_FAILURE, SCMSG_CATEGORY_AUDIT, MSG_JLOG_INFORMATIONAL, LOG_NOTICE)
  34. MAKE_AUDIT_TYPE(ACCESS_SUCCESS, EVENTLOG_AUDIT_SUCCESS, SCMSG_CATEGORY_AUDIT, MSG_JLOG_INFORMATIONAL, LOG_INFO)
  35. MAKE_AUDIT_TYPE(AUDIT_LOG_FAILURE, EVENTLOG_AUDIT_FAILURE, SCMSG_CATEGORY_AUDIT, MSG_JLOG_INFORMATIONAL, LOG_NOTICE)
  36. AUDIT_TYPES_END
  37. /* This function is only required in jlog.cpp, where it is used by AuditLogMsgHandler to translate from a LogMsgCategory to an AuditType. It should be kept updated to reflect the available audit types. */
  38. #ifdef CATEGORY_AUDIT_FUNCTION_REQUIRED
  39. AuditType categoryToAuditType(LogMsgCategory const & category)
  40. {
  41. switch (category.queryClass())
  42. {
  43. case MSGCLS_disaster:
  44. case MSGCLS_error:
  45. return AUDIT_TYPE_ERROR;
  46. default:
  47. return AUDIT_TYPE_DEBUG;
  48. }
  49. return AUDIT_TYPE_DEBUG;
  50. }
  51. #endif //CATEGORY_AUDIT_FUNCTION_REQUIRED