Skip to content

- fixed logging during shutdown#415

Merged
aschnell merged 7 commits intoopenSUSE:masterfrom
aschnell:master
Jul 24, 2018
Merged

- fixed logging during shutdown#415
aschnell merged 7 commits intoopenSUSE:masterfrom
aschnell:master

Conversation

@aschnell
Copy link
Member

@okurz
Copy link
Member

okurz commented Jul 24, 2018

+1 but the git commit message subject lines with leading '-' look unusual

Copy link
Member

@lslezak lslezak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor questions/comments...

boost::lock_guard<boost::mutex> lock(logger_data->mutex);

FILE* f = fopen(filename->c_str(), "ae");
FILE* f = fopen(logger_data->filename.c_str(), "ae");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question, I'm not a C++ expert, there is no C++ equivalent for this plain C fopen?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is ofsteam. But "e" flag (O_CLOEXEC) cannot be provided there AFAIR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, it seems C++ does not support O_CLOEXEC... 😟

void
MetaSnappers::unload()
{
for (iterator it = entries.begin(); it != entries.end(); ++it)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NP: I'd prefer the new syntax without iterators and increment:

for(auto& entry : entries)
    entry.unload();

Copy link
Member Author

@aschnell aschnell Jul 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Snapper still uses the old syntax since it was created mainly before C++11. Many more things could maybe be moderized, e.g. use of C++11 regex and thread. That would even remove the dependency on boost-thread.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, but could we use the new syntax while we are touching the code anyway? In YaST we also still have a lot of YCP-like Ruby code but we are gradually rewriting it to pure Ruby when touching it. Would this approach work also for snapper?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I have changed it to the new C++11 syntax. But given the current activity of the snapper project there will be a mixture of syntaxes for many years.


struct LoggerData
{
LoggerData() : filename("/var/log/snapper.log"), mutex() {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NP: This string is hardcoded in several places, it would be nice to have a constant for it to have a single place to change. BTW the log file is not configurable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a define.

No, the log filename is not configurable. You would also need to modify logrotate in that case so it is not easy.

Copy link
Member

@lslezak lslezak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

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

Successfully merging this pull request may close these issues.

3 participants