log.h 919 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef CCAN_LOG_H
  2. #define CCAN_LOG_H
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <stdbool.h>
  6. #include <stdarg.h>
  7. #include <time.h>
  8. #define LOG_CRITICAL 0
  9. #define LOG_ERROR 1
  10. #define LOG_WARNING 2
  11. #define LOG_INFO 3
  12. #define LOG_INVALID 4
  13. static
  14. char *log_tags[2][5] = { { "[CRITICAL] ",
  15. "[ERROR] ",
  16. "[WARNING] ",
  17. "[INFO] ",
  18. "[INVALID LOG LEVEL] "},
  19. { "[!] ",
  20. "[*] ",
  21. "[-] ",
  22. "[+] ",
  23. "[~] " }};
  24. #define LOG_VERBOSE 0
  25. #define LOG_CONCISE 1
  26. extern FILE *set_log_file(char *);
  27. extern int get_log_mode();
  28. extern void set_log_mode(int);
  29. #define print_log(level, ...) do { \
  30. time_t _clk = time(NULL); \
  31. _print_log(level, __FILE__, __func__, ctime(&_clk), __LINE__, __VA_ARGS__); \
  32. } while (0)
  33. extern void _print_log(int, char *, const char *, char*, int, char *, ...);
  34. #endif // CCAN_LOG_H