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.

34 lines
925B

  1. #pragma once
  2. namespace rack {
  3. namespace logger {
  4. enum Level {
  5. DEBUG_LEVEL,
  6. INFO_LEVEL,
  7. WARN_LEVEL,
  8. FATAL_LEVEL
  9. };
  10. void init(bool devMode);
  11. void destroy();
  12. /** Do not use this function directly. Use the macros below. */
  13. void log(Level level, const char *filename, int line, const char *format, ...);
  14. /** Example usage:
  15. DEBUG("error: %d", errno);
  16. will print something like
  17. [0.123 debug myfile.cpp:45] error: 67
  18. */
  19. #define DEBUG(format, ...) rack::logger::log(rack::logger::DEBUG_LEVEL, __FILE__, __LINE__, format, ##__VA_ARGS__)
  20. #define INFO(format, ...) rack::logger::log(rack::logger::INFO_LEVEL, __FILE__, __LINE__, format, ##__VA_ARGS__)
  21. #define WARN(format, ...) rack::logger::log(rack::logger::WARN_LEVEL, __FILE__, __LINE__, format, ##__VA_ARGS__)
  22. #define FATAL(format, ...) rack::logger::log(rack::logger::FATAL_LEVEL, __FILE__, __LINE__, format, ##__VA_ARGS__)
  23. } // namespace logger
  24. } // namespace rack