You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.6 KiB

2 months ago
  1. Logging {#logging}
  2. ==================
  3. ## Logging frontend
  4. The frontend for logging is defined in [logging.h](@ref logging.h).
  5. It provides the following macros for logging:
  6. - LOGMSG_TRACE(channel, msg)
  7. - LOGMSG_DEBUG(channel, msg)
  8. - LOGMSG_INFO(channel, msg)
  9. - LOGMSG_WARN(channel, msg)
  10. - LOGMSG_ERROR(channel, msg)
  11. - LOGMSG_FATAL(channel, msg)
  12. - LOG_FUNC(channel, args)
  13. - LOG_FUNC(channel, args, msg)
  14. - LOG_ASSERT(channel, condition, msg)
  15. - LOG_NOTIMPLEMENTED()
  16. - LOG_INEFFICIENT()
  17. Where the arguments mean the following:
  18. - `channel`: A string describing the context. For example `"carl.core"`.
  19. - `msg`: The actual message as an expression that can be sent to a std::stringstream. For example `"foo: " << foo`.
  20. - `args`: A description of the function arguments as an expression like `msg`.
  21. - `condition`: A boolean expression that can be passed to `assert()`.
  22. Typically, logging looks like this:
  23. @code{.cpp}
  24. bool checkStuff(Object o, bool flag) {
  25. LOG_FUNC("carl", o << ", " << flag);
  26. bool result = o.property(flag);
  27. LOGMSG_TRACE("carl", "Result: " << result);
  28. return result;
  29. }
  30. @endcode
  31. Logging is enabled (or disabled) by the `LOGGING` macro in CMake.
  32. ## Logging configuration
  33. As of now, there is no frontend interface to configure logging.
  34. Hence, configuration is performed directly on the backend.
  35. ## Logging backends
  36. As of now, only two logging backends exist.
  37. ### CArL logging
  38. CArL provides a custom logging mechanism defined in carl::logging.
  39. ### Fallback logging
  40. If logging is enabled, but no real logging backend is selected, all logging of level `WARN` or above goes to `std::cerr`.