debug.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef DEBUG_H
  7. #define DEBUG_H
  8. #include <stdio.h>
  9. /* The log output macros print output to the console. These macros produce
  10. * compiled log output only if the LOG_LEVEL defined in the makefile (or the
  11. * make command line) is greater or equal than the level required for that
  12. * type of log output.
  13. * The format expected is the same as for printf(). For example:
  14. * INFO("Info %s.\n", "message") -> INFO: Info message.
  15. * WARN("Warning %s.\n", "message") -> WARNING: Warning message.
  16. */
  17. #define LOG_LEVEL_NONE 0
  18. #define LOG_LEVEL_ERROR 10
  19. #define LOG_LEVEL_NOTICE 20
  20. #define LOG_LEVEL_WARNING 30
  21. #define LOG_LEVEL_INFO 40
  22. #define LOG_LEVEL_VERBOSE 50
  23. #if LOG_LEVEL >= LOG_LEVEL_NOTICE
  24. # define NOTICE(...) printf("NOTICE: " __VA_ARGS__)
  25. #else
  26. # define NOTICE(...)
  27. #endif
  28. #if LOG_LEVEL >= LOG_LEVEL_ERROR
  29. # define ERROR(...) printf("ERROR: " __VA_ARGS__)
  30. #else
  31. # define ERROR(...)
  32. #endif
  33. #if LOG_LEVEL >= LOG_LEVEL_WARNING
  34. # define WARN(...) printf("WARNING: " __VA_ARGS__)
  35. #else
  36. # define WARN(...)
  37. #endif
  38. #if LOG_LEVEL >= LOG_LEVEL_INFO
  39. # define INFO(...) printf("INFO: " __VA_ARGS__)
  40. #else
  41. # define INFO(...)
  42. #endif
  43. #if LOG_LEVEL >= LOG_LEVEL_VERBOSE
  44. # define VERBOSE(...) printf("VERBOSE: " __VA_ARGS__)
  45. #else
  46. # define VERBOSE(...)
  47. #endif
  48. #endif /* DEBUG_H */