Make Trunk-Recorder logrotate friendly, via syslogFriendly bool config option.
#1080
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
More testing is required for a few days before this is merged in, I want to make sure it works as intended before pulled.
Added a
syslogFriendlyconfig option, that by default isfalse. When set totruecreates atrunk-recorder.logfile that can be rotated with logrotate. Logrotate sends aSIGHUPsignal that is handled by this change. Closes #833.Implementation Summary
Changes Made:
trunk-recorder/global_structs.h:39 - Added
bool syslog_friendlyfield to the Config structtrunk-recorder/config.cc:
setup_file_log()to acceptsyslog_friendlyparametersyslog_friendlyis true, uses static filenametrunk-recorder.loginstead of timestamped%m-%d-%Y_%H%M_%2N.logsyslog_friendlyis true, disables automatic rotation (no rotation_size or time_based_rotation)syslogFriendlyoption (defaults to false)trunk-recorder/monitor_systems.cc:
rotate_log_signal)rotate_log_flagto safely handle signal in main loopHow to Use:
Add this to your
config.json:{ "logFile": true, "logDir": "logs", "syslogFriendly": true, ... }Example logrotate Configuration:
Create
/etc/logrotate.d/trunk-recorder:Behavior:
syslogFriendly: false): Uses timestamped log files with automatic rotation at 100MB or dailysyslogFriendly: true):trunk-recorder.log