Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rotating_file_handler unable to log to /dev/null #297

Closed
dirocco opened this issue May 26, 2023 · 2 comments
Closed

rotating_file_handler unable to log to /dev/null #297

dirocco opened this issue May 26, 2023 · 2 comments

Comments

@dirocco
Copy link

dirocco commented May 26, 2023

After upgrading from 1.6.3 to 2.9.0, I'm no longer able to use "/dev/null" as a file name for quill::rotating_file_hander. This is useful for exercising quill and custom fmt types during tests without actually writing to disk.

The error is in quill/src/detail/misc/FileUtilities.cpp where std::filesystem::file_size throws an uncaught exception when RotatingFileHandler.cpp tries to set _current_size:
size_t file_size(fs::path const& filename) { return static_cast<size_t>(fs::file_size(filename)); }

Here is the exception text:
filesystem error: cannot get file size: Operation not supported [/dev/null]

@dirocco dirocco changed the title Quill unable to log to /dev/null rotating_file_handler unable to log to /dev/null May 26, 2023
@odygrd
Copy link
Owner

odygrd commented May 27, 2023

hey, thanks for reporting this. I have added support to RotatingFileHandler and TimeRotatingFileHandler for /dev/null in latest master.

I have also added the NullHandler class.

Another way to skip logs completely is to never call quill::start() in your testing, that way the logs are only pushed to the unbounded queues but are never processed. But for more complete regression testing it's better to use /dev/null or the NullHandler as it will also process the log statements during your testing.

@odygrd
Copy link
Owner

odygrd commented May 28, 2023

fix is in v2.9.1. closing for now, if you have any issues let me know

@odygrd odygrd closed this as completed May 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants