Add log rotation (#6564)

* Use flexi_logger; Add log rotation

* Add default rotation; Add FlexiLogger error

* Fix compilation error

* Remove logging to stdout if it's not a tty

* Fix formatting

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Remove needless debug statement

* Default to unlimited size for log rotation

* Add more comments about log-age option

* Remove unused variable

* Fix typo in comment

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
pscott
2020-07-08 12:11:09 +02:00
committed by GitHub
parent 62f306d972
commit 6eb2eb81c5
8 changed files with 324 additions and 84 deletions
@@ -19,8 +19,10 @@
use sc_service::config::BasePath;
use std::path::PathBuf;
use structopt::StructOpt;
use crate::logger::LogRotationOpt;
/// Shared parameters used by all `CoreParams`.
#[allow(missing_docs)]
#[derive(Debug, StructOpt)]
pub struct SharedParams {
/// Specify the chain specification (one of dev, local, or staging).
@@ -41,6 +43,9 @@ pub struct SharedParams {
/// By default, all targets log `info`. The global log level can be set with -l<level>.
#[structopt(short = "l", long, value_name = "LOG_PATTERN")]
pub log: Vec<String>,
#[structopt(flatten)]
pub log_rotation_opt: LogRotationOpt,
}
impl SharedParams {
@@ -72,4 +77,9 @@ impl SharedParams {
pub fn log_filters(&self) -> &[String] {
&self.log
}
/// Get the file rotation options for the logging
pub fn log_rotation_opt(&self) -> &LogRotationOpt {
&self.log_rotation_opt
}
}