Replace logging backend to log4rs and add log rotation (#1789)

* Replace logging backend to flexi-logger and add log rotation
* Changed flexi_logger to log4rs
* Disable logging level filtering in Root logger
* Support different logging levels for file and stdout
* Don't log messages from modules other than Grin-related
* Fix formatting
* Place backed up compressed log copies into log file directory
* Increase default log file size to 16 MiB
* Add comment to config file on log_max_size option
This commit is contained in:
eupn
2018-10-21 23:30:56 +03:00
committed by Ignotus Peverell
parent 0852b0c4cf
commit 1195071f5b
83 changed files with 582 additions and 897 deletions
+5 -8
View File
@@ -20,7 +20,6 @@ use chain;
use common::types::{Error, SyncState, SyncStatus};
use core::core::hash::{Hash, Hashed};
use p2p::{self, Peer};
use util::LOGGER;
pub struct HeaderSync {
sync_state: Arc<SyncState>,
@@ -60,7 +59,6 @@ impl HeaderSync {
// but ONLY on initial transition to HeaderSync state.
let sync_head = self.chain.get_sync_head().unwrap();
debug!(
LOGGER,
"sync: initial transition to HeaderSync. sync_head: {} at {}, reset to: {} at {}",
sync_head.hash(),
sync_head.height,
@@ -141,8 +139,8 @@ impl HeaderSync {
fn request_headers(&mut self, peer: &Peer) {
if let Ok(locator) = self.get_locator() {
debug!(
LOGGER,
"sync: request_headers: asking {} for headers, {:?}", peer.info.addr, locator,
"sync: request_headers: asking {} for headers, {:?}",
peer.info.addr, locator,
);
let _ = peer.send_header_request(locator);
@@ -165,7 +163,7 @@ impl HeaderSync {
self.history_locators.clear();
}
debug!(LOGGER, "sync: locator heights : {:?}", heights);
debug!("sync: locator heights : {:?}", heights);
let mut locator: Vec<Hash> = vec![];
let mut current = self.chain.get_block_header(&tip.last_block_h);
@@ -237,7 +235,7 @@ impl HeaderSync {
}
}
debug!(LOGGER, "sync: locator heights': {:?}", new_heights);
debug!("sync: locator heights': {:?}", new_heights);
// shrink history_locators properly
if heights.len() > 1 {
@@ -258,14 +256,13 @@ impl HeaderSync {
}
}
debug!(
LOGGER,
"sync: history locators: len={}, shrunk={}",
self.history_locators.len(),
shrunk_size
);
}
debug!(LOGGER, "sync: locator: {:?}", locator);
debug!("sync: locator: {:?}", locator);
Ok(locator)
}