debug.h 951 B

123456789101112131415161718192021222324252627282930
  1. /* Copyright (c) 2017-2019, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /**
  4. * \file debug.h
  5. * \brief Macros for debugging our event-trace support.
  6. **/
  7. #ifndef TOR_TRACE_LOG_DEBUG_H
  8. #define TOR_TRACE_LOG_DEBUG_H
  9. #include "lib/log/log.h"
  10. /* Stringify pre-processor trick. */
  11. #define XSTR(d) STR(d)
  12. #define STR(s) #s
  13. /* Send every event to a debug log level. This is useful to debug new trace
  14. * events without implementing them for a specific event tracing framework.
  15. * Note that the arguments are ignored since at this step we do not know the
  16. * types and amount there is. */
  17. /* Example on how to map a tracepoint to log_debug(). */
  18. #undef tor_trace
  19. #define tor_trace(subsystem, name, args...) \
  20. log_debug(LD_GENERAL, "Trace event \"" XSTR(name) "\" from " \
  21. "\"" XSTR(subsystem) "\" hit. " \
  22. "(line "XSTR(__LINE__) ")")
  23. #endif /* !defined(TOR_TRACE_LOG_DEBUG_H) */