logger.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * logger.h
  3. *
  4. * Created on: Feb 3, 2016
  5. * Author: Philipp Hinz
  6. */
  7. #ifndef LOGGER_H_
  8. #define LOGGER_H_
  9. // Logtypes for coloring
  10. typedef enum {
  11. LOG_INFO = 0,
  12. LOG_CAN = 1,
  13. LOG_OK = 2,
  14. LOG_WARN = 3,
  15. LOG_ERROR = 4,
  16. LOG_ERRORC = 5,
  17. } logger_type_t;
  18. // verbosity levels
  19. typedef enum {
  20. V_NONE = 0,
  21. V_BASIC = 1,
  22. V_BREW = 2,
  23. V_HAL = 3,
  24. V_SQL = 4,
  25. V_STRIPE = 5,
  26. V_SPI = 6,
  27. } logger_verbose_t;
  28. // Colors \o/
  29. #define USE_COLORS
  30. // List of escape sequences http://ascii-table.com/ansi-escape-sequences.php
  31. #ifdef USE_COLORS
  32. #define KNRM "\x1B[0m"
  33. #define KRED "\x1B[31m"
  34. #define KGRN "\x1B[32m"
  35. #define KYEL "\x1B[33m"
  36. #define KBLU "\x1B[34m"
  37. #define KMAG "\x1B[35m"
  38. #define KCYN "\x1B[36m"
  39. #define KWHT "\x1B[37m"
  40. #else
  41. #define KNRM
  42. #define KRED
  43. #define KGRN
  44. #define KYEL
  45. #define KBLU
  46. #define KMAG
  47. #define KCYN
  48. #define KWHT
  49. #endif
  50. #define CLEARLINE "\x1B[100D\x1B[1A\x1B[K"
  51. #define KBOLD "\x1B[1m"
  52. void logger_error( const char* format, ... );
  53. void logger_reset();
  54. void logger(logger_verbose_t verboselevel, logger_type_t logtype, const char* format, ... );
  55. void logger(logger_verbose_t verboselevel, const char* format, ... );
  56. #endif /* LOGGER_H_ */