location_info.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #define WIDEN2(x) L ## x
  11. #define WIDEN(x) WIDEN2(x)
  12. #define __WFILE__ WIDEN(__FILE__)
  13. #define __WFUNCTION__ WIDEN(__FUNCTION__)
  14. /**
  15. * @file location_info.h
  16. *
  17. * @brief The internal representation of caller location information.
  18. *
  19. * When a affirmative logging decision is made a log4c_location_info_t is
  20. * created and is passed around the different log4c components.
  21. **/
  22. ///#include <log4c/defs.h>
  23. __LOG4C_BEGIN_DECLS
  24. /**
  25. * @brief logging location information
  26. *
  27. * Attributes description:
  28. *
  29. * @li @c loc_file file name
  30. * @li @c loc_line file line
  31. * @li @c loc_function function name
  32. * @li @c loc_data user data
  33. *
  34. * @todo this is not used
  35. **/
  36. typedef struct
  37. {
  38. const TCHAR* loc_file;
  39. int loc_line;
  40. const TCHAR* loc_function;
  41. void* loc_data;
  42. } log4c_location_info_t;
  43. /**
  44. * log4c_location_info_t initializer
  45. **/
  46. #ifdef __GNUC__
  47. # define LOG4C_LOCATION_INFO_INITIALIZER(user_data) { __FILE__, __LINE__, __FUNCTION__, user_data }
  48. #else
  49. #ifdef UNICODE
  50. #define LOG4C_LOCATION_INFO_INITIALIZER(user_data) { __WFILE__, __LINE__, _T("(nil)"), user_data }
  51. #else
  52. #define LOG4C_LOCATION_INFO_INITIALIZER(user_data) { __FILE__, __LINE__, _T("(nil)"), user_data }
  53. #endif
  54. #endif
  55. #define __log4c_str(n) #n
  56. #ifdef __GNUC__
  57. # define __log4c_location(n) __FUNCTION__ "() at " __FILE__ ":" __log4c_str(n)
  58. #else
  59. #ifdef UNICODE
  60. #define __log4c_location(n) __WFILE__ _T(":") __log4c_str(n)
  61. #else
  62. #define __log4c_location(n) __FILE__ _T(":") __log4c_str(n)
  63. #endif
  64. #endif
  65. /**
  66. * This macro returns the literal representation of a logging event
  67. * location
  68. **/
  69. #define log4c_location __log4c_location(__LINE__)
  70. __LOG4C_END_DECLS
  71. #endif