location_info.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* $Id$
  2. *
  3. * location_info.h
  4. *
  5. * Copyright 2001-2003, Meiosys (www.meiosys.com). All rights reserved.
  6. * See the COPYING file for the terms of usage and distribution.
  7. */
  8. #ifndef log4c_location_info_h
  9. #define log4c_location_info_h
  10. /**
  11. * @file location_info.h
  12. *
  13. * @brief The internal representation of caller location information.
  14. *
  15. * When a affirmative logging decision is made a log4c_location_info_t is
  16. * created and is passed around the different log4c components.
  17. **/
  18. ///#include <log4c/defs.h>
  19. __LOG4C_BEGIN_DECLS
  20. /**
  21. * @brief logging location information
  22. *
  23. * Attributes description:
  24. *
  25. * @li @c loc_file file name
  26. * @li @c loc_line file line
  27. * @li @c loc_function function name
  28. * @li @c loc_data user data
  29. *
  30. * @todo this is not used
  31. **/
  32. typedef struct
  33. {
  34. const char* loc_file;
  35. int loc_line;
  36. const char* loc_function;
  37. void* loc_data;
  38. } log4c_location_info_t;
  39. /**
  40. * log4c_location_info_t initializer
  41. **/
  42. #ifdef __GNUC__
  43. # define LOG4C_LOCATION_INFO_INITIALIZER(user_data) { __FILE__, __LINE__, __FUNCTION__, user_data }
  44. #else
  45. # define LOG4C_LOCATION_INFO_INITIALIZER(user_data) { __FILE__, __LINE__, "(nil)", user_data }
  46. #endif
  47. #define __log4c_str(n) #n
  48. #ifdef __GNUC__
  49. # define __log4c_location(n) __FUNCTION__ "() at " __FILE__ ":" __log4c_str(n)
  50. #else
  51. # define __log4c_location(n) __FILE__ ":" __log4c_str(n)
  52. #endif
  53. /**
  54. * This macro returns the literal representation of a logging event
  55. * location
  56. **/
  57. #define log4c_location __log4c_location(__LINE__)
  58. __LOG4C_END_DECLS
  59. #endif