-
-
Notifications
You must be signed in to change notification settings - Fork 928
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
Enable reopening log files #595
base: master
Are you sure you want to change the base?
Conversation
Apparently unit test fails, I haven't looked at them yet. Any comment on this change, does it break the architecture? Or is it just the tests that need to be updated? |
04d5c2b
to
20c560d
Compare
Tests passes when I run them locally with my latest update. Travis CI build seem to have some problem with cmake when building googletest. |
20c560d
to
fdc76d5
Compare
LogStreamReferenceMap was keeping a reference to FileStream which kept the file open even though Logger was unregistred.
fdc76d5
to
41ef65e
Compare
I would love to see this added, as without using the linux |
if (!needNewStream && filestreamIter->second.lock() == nullptr) { | ||
// Filestream is expired and exists in map | ||
needNewStream = true; | ||
m_logStreamsReference->erase(filestreamIter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There may still be some remaining elements in map that can't be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get that can't be removed
.
This erase only one expired file stream.
If it is not expired, why remove?
Once a Logger is configured the application keeps the file open. This is due to that
LogStreamReferenceMap
is keeping a reference to the FileStream object and unregistering the Logger will never close the file.Switching to weak_ptr in
LogStreamReferenceMap
i.e. not holding a reference makes unregistering logger close the file if no other reference to FileStream object exist.The use case is for logrotation where logrotation removes the logfile and sends a SIGHUP to the application. This fix makes it possible to reconfigure the logger to reopen the log file. I added a sample to illustrate the use case.
This is a
I have
CHANGELOG.md
README.md