log.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef VIRTUALMATH_LOG_H
  2. #define VIRTUALMATH_LOG_H
  3. #include "__macro.h"
  4. #define DEEP_DEBUG -3
  5. #define LEXICAL_CHECKOUT_DEBUG -3
  6. #define LEXICAL_DEBUG -2
  7. #define GRAMMAR_DEBUG -1
  8. #define DEBUG 0
  9. #define INFO 1
  10. #define WARNING 2
  11. #define ERROR 3
  12. #ifndef OUT_INTER_LOG
  13. #define OUT_INTER_LOG true
  14. #endif
  15. #ifndef OUT_TOKEN_LOG
  16. #define OUT_TOKEN_LOG true
  17. #endif
  18. #ifndef OUT_PASERS_LOG
  19. #define OUT_PASERS_LOG true
  20. #endif
  21. #ifndef OUT_GRAMMER_LOG
  22. #define OUT_GRAMMER_LOG true
  23. #endif
  24. #ifndef OUT_LOG
  25. #define OUT_LOG true
  26. #endif
  27. #if OUT_LOG
  28. #define writeLog(file, info_level, message, ...) do{ \
  29. if (file == NULL || info_level < args.level){ \
  30. break; \
  31. } \
  32. else{ \
  33. fprintf(file, message, __VA_ARGS__); \
  34. } \
  35. } while(0)
  36. #else
  37. /* 不输出日志 */
  38. #define writeLog(...) PASS
  39. #define doubleLog(...) PASS
  40. #endif
  41. #ifdef __unix__
  42. #define GRAMMAR_LOG "/grammar.log"
  43. #define PASERS_LOG "/pasers.log"
  44. #define LEXICAL_LOG "/lexical.log"
  45. #define INTER_LOG "/inter.log"
  46. #define INTER_ERROR "/error.log"
  47. #else
  48. #define GRAMMAR_LOG "\grammar.log"
  49. #define PASERS_LOG "\pasers.log"
  50. #define LEXICAL_LOG "\lexical.log"
  51. #define INTER_LOG "\inter.log"
  52. #define INTER_ERROR "\error.log"
  53. #endif
  54. #endif //VIRTUALMATH_LOG_H