cmu-db / bustub

The BusTub Relational Database Management System (Educational)
https://15445.courses.cs.cmu.edu
MIT License
4.12k stars 1.81k forks source link

fix(logging): LOG_LEVEL doesn't work #505

Closed xiaguan closed 1 year ago

xiaguan commented 1 year ago

The #if command only finds the macro definition. If it is not found, it defaults to 0. But LOG_LEVEL is a C++'s constexpr variable which the compiler will process after the #if command. So what ever the LOG_LEVEL is , the logger will print all log. If you still want to use constexpr variable , maybe you should use the template technology instead of #if. In my opinion, it is feasible and inexpensive to simply replace it with a macro definition. Finally, a new function suggests that for concurrent programs, the log should carry the thread id, and users can simply control the format, log level filtering, or users prefer streaming output log, and so on. If you need, I can provide header-only one.

skyzh commented 1 year ago

We will get this merged this Sunday so as to avoid breaking some students' setup.

skyzh commented 1 year ago

... it's the deadline for project 1 and the start of project 2

xiaguan commented 1 year ago

This is the first time I use pull request. Not familiar with the process, sorry.

skyzh commented 1 year ago

Don’t worry, you are on the right track!