logging_event.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* $Id$
  2. *
  3. * logging_event.h
  4. *
  5. * Copyright 2001-2003, Meiosys (www.meiosys.com). All rights reserved.
  6. *
  7. * See the COPYING file for the terms of usage and distribution.
  8. */
  9. #ifndef log4c_logging_event_h
  10. #define log4c_logging_event_h
  11. /**
  12. * @file logging_event.h
  13. *
  14. * @brief the internal representation of logging events.
  15. *
  16. * When a affirmative logging decision is made a log4c_logging_event
  17. * instance is created. This instance is passed around the different log4c
  18. * components.
  19. **/
  20. #include <log4c/defs.h>
  21. #include <log4c/buffer.h>
  22. #include <log4c/location_info.h>
  23. #if !defined(_WIN32) || defined(__MINGW32__) || defined (__MINGW64__)
  24. #include <sys/time.h>
  25. #endif
  26. __LOG4C_BEGIN_DECLS
  27. struct __log4c_category;
  28. /**
  29. * @brief logging event object
  30. *
  31. * Attributes description:
  32. *
  33. * @li @c evt_category category name.
  34. * @li @c evt_priority priority of logging event.
  35. * @li @c evt_msg The application supplied message of logging event.
  36. * @li @c evt_buffer a pre allocated buffer to be used by layouts to
  37. * format in a multi-thread environment.
  38. * @li @c evt_rendered_msg The application supplied message after layout format.
  39. * @li @c evt_timestamp The number of seconds elapsed since the epoch
  40. * (1/1/1970 00:00:00 UTC) until logging event was created.
  41. * @li @c evt_loc The event's location information
  42. **/
  43. typedef struct
  44. {
  45. const char* evt_category;
  46. int evt_priority;
  47. const char* evt_msg;
  48. const char* evt_rendered_msg;
  49. log4c_buffer_t evt_buffer;
  50. /* ok, this is probably not a good way to do it--should define a common type here
  51. and have the base acessor function do the mapping
  52. */
  53. #if !defined(_WIN32) || defined(__MINGW32__) || defined(__MINGW64__)
  54. #define LOG4C_POSIX_TIMESTAMP 1
  55. struct timeval evt_timestamp;
  56. #else
  57. FILETIME evt_timestamp;
  58. #endif
  59. const log4c_location_info_t* evt_loc;
  60. } log4c_logging_event_t;
  61. /**
  62. * Constructor for a logging event.
  63. *
  64. * @param a_category the category name
  65. * @param a_priority the category initial priority
  66. * @param a_message the message of this event
  67. *
  68. * @todo need to handle multi-threading (NDC)
  69. **/
  70. LOG4C_API log4c_logging_event_t* log4c_logging_event_new(
  71. const char* a_category,
  72. int a_priority,
  73. const char* a_message);
  74. /**
  75. * Destructor for a logging event.
  76. * @param a_event the logging event object
  77. **/
  78. LOG4C_API void log4c_logging_event_delete(log4c_logging_event_t* a_event);
  79. __LOG4C_END_DECLS
  80. #endif