It is currently impossible on windows to make your own log rotation system because to do this you would first have to close the file, then move it under another name, and then reopen the file with the old name.
None of its functions are exposed in loguru.hpp.
However, according to some issues, it is stated that here, that a simple file renaming would automatically reopen the file with LOGURU_FILEABS.
This is wrong, because on Windows you cannot move a file that is still open, you will get a message (This file is currently used by another process).
One solution could be to offer a function that allows you to close the current stream, and then rename the file under another name.
I saw that there is a file_close function exposed in Loguru.cpp which takes a user_data, but it seems to be very internal and unusable from the outside.
For example this code snippet will never work on Windows if we cannot close the file before :
It is currently impossible on windows to make your own log rotation system because to do this you would first have to
close
the file, thenmove
it under another name, and thenreopen
the file with the old name.None of its functions are exposed in loguru.hpp.
However, according to some issues, it is stated that here, that a simple file renaming would automatically reopen the file with
LOGURU_FILEABS
.This is wrong, because on Windows you cannot move a file that is still open, you will get a message (This file is currently used by another process).
One solution could be to offer a function that allows you to close the current stream, and then rename the file under another name.
I saw that there is a file_close function exposed in Loguru.cpp which takes a user_data, but it seems to be very internal and unusable from the outside.
For example this code snippet will never work on Windows if we cannot close the file before :