You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.4 KiB

  1. --- a/CMakeLists.txt
  2. +++ b/CMakeLists.txt
  3. @@ -5,7 +5,6 @@ set(CMAKE_BUILD_TYPE "Debug")
  4. #set(CMAKE_BUILD_TYPE "Release")
  5. #set(CMAKE_C_FLAGS "-Wall -Wextra --pedantic -Wno-strict-aliasing")
  6. -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__FILENAME__='\"$(notdir $<)\"'")
  7. set(CMAKE_C_FLAGS_DEBUG "-g")
  8. set(CMAKE_C_FLAGS_RELEASE "-O2")
  9. --- a/src/logging.h
  10. +++ b/src/logging.h
  11. @@ -34,6 +34,20 @@ enum _LogSeverity {
  12. LOG_FATAL = 4,
  13. };
  14. +#define STRIPPATH(s)\
  15. + (sizeof(s) > 2 && (s)[sizeof(s)-2] == '/' ? (s) + sizeof(s) - 1 : \
  16. + sizeof(s) > 3 && (s)[sizeof(s)-3] == '/' ? (s) + sizeof(s) - 2 : \
  17. + sizeof(s) > 4 && (s)[sizeof(s)-4] == '/' ? (s) + sizeof(s) - 3 : \
  18. + sizeof(s) > 5 && (s)[sizeof(s)-5] == '/' ? (s) + sizeof(s) - 4 : \
  19. + sizeof(s) > 6 && (s)[sizeof(s)-6] == '/' ? (s) + sizeof(s) - 5 : \
  20. + sizeof(s) > 7 && (s)[sizeof(s)-7] == '/' ? (s) + sizeof(s) - 6 : \
  21. + sizeof(s) > 8 && (s)[sizeof(s)-8] == '/' ? (s) + sizeof(s) - 7 : \
  22. + sizeof(s) > 9 && (s)[sizeof(s)-9] == '/' ? (s) + sizeof(s) - 8 : \
  23. + sizeof(s) > 10 && (s)[sizeof(s)-10] == '/' ? (s) + sizeof(s) - 9 : \
  24. + sizeof(s) > 11 && (s)[sizeof(s)-11] == '/' ? (s) + sizeof(s) - 10 : (s))
  25. +
  26. +#define __FILENAME__ STRIPPATH(__FILE__)
  27. +
  28. // Debug, Info, Warning, Error logging.
  29. #define DLOG(...) _log(__FILENAME__, __LINE__, LOG_DEBUG, __VA_ARGS__)
  30. #define ILOG(...) _log(__FILENAME__, __LINE__, LOG_INFO, __VA_ARGS__)