log.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #else
  47. #define GRAMMAR_LOG "\grammar.log"
  48. #define PASERS_LOG "\pasers.log"
  49. #define LEXICAL_LOG "\lexical.log"
  50. #define INTER_LOG "\inter.log"
  51. #endif
  52. #endif //VIRTUALMATH_LOG_H