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

add a new configure item for log_max_files #2601

Merged
merged 4 commits into from
Mar 8, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions config/src/comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,14 @@ fn comments() -> HashMap<String, String> {
.to_string(),
);

retval.insert(
"log_max_files".to_string(),
"
#maximum count of the log files to rotate over
"
.to_string(),
);

retval
}

Expand Down
3 changes: 2 additions & 1 deletion util/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ pub fn init_logger(config: Option<LoggingConfig>) {
let filter = Box::new(ThresholdFilter::new(level_file));
let file: Box<dyn Append> = {
if let Some(size) = c.log_max_size {
let count = c.log_max_files.unwrap_or_else(|| 32);
let roller = FixedWindowRoller::builder()
.build(&format!("{}.{{}}.gz", c.log_file_path), 32)
.build(&format!("{}.{{}}.gz", c.log_file_path), count)
.unwrap();
let trigger = SizeTrigger::new(size);

Expand Down
3 changes: 3 additions & 0 deletions util/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ pub struct LoggingConfig {
pub log_file_append: bool,
/// Size of the log in bytes to rotate over (optional)
pub log_max_size: Option<u64>,
/// Number of the log files to rotate over (optional)
pub log_max_files: Option<u32>,
/// Whether the tui is running (optional)
pub tui_running: Option<bool>,
}
Expand All @@ -60,6 +62,7 @@ impl Default for LoggingConfig {
log_file_path: String::from("grin.log"),
log_file_append: true,
log_max_size: Some(1024 * 1024 * 16), // 16 megabytes default
log_max_files: Some(32), // 32 log files to rotate over by default
garyyu marked this conversation as resolved.
Show resolved Hide resolved
tui_running: None,
}
}
Expand Down