events.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* Copyright (c) 2017, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /**
  4. * \file events.h
  5. * \brief Header file for Tor event tracing.
  6. **/
  7. #ifndef TOR_TRACE_EVENTS_H
  8. #define TOR_TRACE_EVENTS_H
  9. /*
  10. * The following defines a generic event tracing function name that has to be
  11. * used to trace events in the code base.
  12. *
  13. * That generic function is then defined by a event tracing framework. For
  14. * instance, the "log debug" framework sends all trace events to log_debug()
  15. * which is defined in src/trace/debug.h which can only be enabled at compile
  16. * time (--enable-event-tracing-debug).
  17. *
  18. * By default, every trace events in the code base are replaced by a NOP. See
  19. * doc/HACKING/Tracing.md for more information on how to use event tracing or
  20. * add events.
  21. */
  22. #ifdef TOR_EVENT_TRACING_ENABLED
  23. /* Map every trace event to a per subsystem macro. */
  24. #define tor_trace(subsystem, name, ...) \
  25. tor_trace_##subsystem(name, __VA_ARGS__)
  26. /* Enable event tracing for the debug framework where all trace events are
  27. * mapped to a log_debug(). */
  28. #ifdef USE_EVENT_TRACING_DEBUG
  29. #include "trace/debug.h"
  30. #endif
  31. #else /* TOR_EVENT_TRACING_ENABLED */
  32. /* Reaching this point, we NOP every event declaration because event tracing
  33. * is not been enabled at compile time. */
  34. #define tor_trace(subsystem, name, args...)
  35. #endif /* TOR_EVENT_TRACING_ENABLED */
  36. #endif /* TOR_TRACE_EVENTS_H */