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

Make logging logrotate friendly #833

Open
bctrainers opened this issue Jul 9, 2023 · 1 comment
Open

Make logging logrotate friendly #833

bctrainers opened this issue Jul 9, 2023 · 1 comment
Labels
enhancement PR requested Asked issued submitter for a PR

Comments

@bctrainers
Copy link

This issue pertains to this segment of main.cc:

if (config.log_file) {
logging::add_file_log(
keywords::file_name = config.log_dir + "/%m-%d-%Y_%H%M_%2N.log",
keywords::format = "[%TimeStamp%] (%Severity%) %Message%",
keywords::rotation_size = 100 * 1024 * 1024,
keywords::time_based_rotation = sinks::file::rotation_at_time_point(0, 0, 0),
keywords::auto_flush = true);
}

The addition of a toggled global option within the config file to make logging friendly to logrotate syslog-styled logs. The option within the config.json would be a global option called syslogFriendly as a boolean.

What would this request do exactly? If syslogFriendly is set to true, a new function would be utilized within the segment of code above.

  1. The file_name directive would become trunk-recorder.log while respecting config.log_dir and config.log_file string and boolean respectively.
  2. The log would have no date-time prefix due to # 1 (ex; 07-09-2023_0516_00.log).
  3. No built-in log rotation would occur. That would be on logrotate to truncate the current log file.
  4. TrunkRecorder must check for file existence when writing to trunk-recorder.log - as such, SIGHUP or another signal would need to be used and captured on Trunk-Recorders' end.

This code addition would likely require the addition of text_file_backend::rotate_file() from boost when a signal is utilized.

@robotastic
Copy link
Owner

This seems like a good idea - would you be able to give it a try and make a PR?

@robotastic robotastic added the PR requested Asked issued submitter for a PR label Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement PR requested Asked issued submitter for a PR
Projects
None yet
Development

No branches or pull requests

2 participants