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:
+10
-21
@@ -35,7 +35,6 @@ use grin_store;
|
||||
use store;
|
||||
use txhashset;
|
||||
use types::{Options, Tip};
|
||||
use util::LOGGER;
|
||||
|
||||
/// Contextual information required to process a new block and either reject or
|
||||
/// accept it.
|
||||
@@ -71,7 +70,6 @@ pub fn process_block(b: &Block, ctx: &mut BlockContext) -> Result<Option<Tip>, E
|
||||
// spend resources reading the full block when its header is invalid
|
||||
|
||||
debug!(
|
||||
LOGGER,
|
||||
"pipe: process_block {} at {} with {} inputs, {} outputs, {} kernels",
|
||||
b.hash(),
|
||||
b.header.height,
|
||||
@@ -168,7 +166,6 @@ pub fn process_block(b: &Block, ctx: &mut BlockContext) -> Result<Option<Tip>, E
|
||||
})?;
|
||||
|
||||
trace!(
|
||||
LOGGER,
|
||||
"pipe: process_block: {} at {} is valid, save and append.",
|
||||
b.hash(),
|
||||
b.header.height,
|
||||
@@ -190,7 +187,6 @@ pub fn sync_block_headers(
|
||||
) -> Result<Option<Tip>, Error> {
|
||||
if let Some(header) = headers.first() {
|
||||
debug!(
|
||||
LOGGER,
|
||||
"pipe: sync_block_headers: {} headers from {} at {}",
|
||||
headers.len(),
|
||||
header.hash(),
|
||||
@@ -251,7 +247,6 @@ pub fn sync_block_headers(
|
||||
/// it.
|
||||
pub fn process_block_header(header: &BlockHeader, ctx: &mut BlockContext) -> Result<(), Error> {
|
||||
debug!(
|
||||
LOGGER,
|
||||
"pipe: process_block_header: {} at {}",
|
||||
header.hash(),
|
||||
header.height,
|
||||
@@ -356,8 +351,8 @@ fn validate_header(header: &BlockHeader, ctx: &mut BlockContext) -> Result<(), E
|
||||
// check version, enforces scheduled hard fork
|
||||
if !consensus::valid_header_version(header.height, header.version) {
|
||||
error!(
|
||||
LOGGER,
|
||||
"Invalid block header version received ({}), maybe update Grin?", header.version
|
||||
"Invalid block header version received ({}), maybe update Grin?",
|
||||
header.version
|
||||
);
|
||||
return Err(ErrorKind::InvalidBlockVersion(header.version).into());
|
||||
}
|
||||
@@ -378,8 +373,8 @@ fn validate_header(header: &BlockHeader, ctx: &mut BlockContext) -> Result<(), E
|
||||
let edge_bits = header.pow.edge_bits();
|
||||
if !(ctx.pow_verifier)(header, edge_bits).is_ok() {
|
||||
error!(
|
||||
LOGGER,
|
||||
"pipe: error validating header with cuckoo edge_bits {}", edge_bits
|
||||
"pipe: error validating header with cuckoo edge_bits {}",
|
||||
edge_bits
|
||||
);
|
||||
return Err(ErrorKind::InvalidPow.into());
|
||||
}
|
||||
@@ -434,7 +429,6 @@ fn validate_header(header: &BlockHeader, ctx: &mut BlockContext) -> Result<(), E
|
||||
let next_header_info = consensus::next_difficulty(header.height, diff_iter);
|
||||
if target_difficulty != next_header_info.difficulty {
|
||||
info!(
|
||||
LOGGER,
|
||||
"validate_header: header target difficulty {} != {}",
|
||||
target_difficulty.to_num(),
|
||||
next_header_info.difficulty.to_num()
|
||||
@@ -548,8 +542,8 @@ fn update_head(b: &Block, ctx: &BlockContext) -> Result<Option<Tip>, Error> {
|
||||
.map_err(|e| ErrorKind::StoreErr(e, "pipe save body".to_owned()))?;
|
||||
|
||||
debug!(
|
||||
LOGGER,
|
||||
"pipe: head updated to {} at {}", tip.last_block_h, tip.height
|
||||
"pipe: head updated to {} at {}",
|
||||
tip.last_block_h, tip.height
|
||||
);
|
||||
|
||||
Ok(Some(tip))
|
||||
@@ -569,7 +563,7 @@ fn update_sync_head(bh: &BlockHeader, batch: &mut store::Batch) -> Result<(), Er
|
||||
batch
|
||||
.save_sync_head(&tip)
|
||||
.map_err(|e| ErrorKind::StoreErr(e, "pipe save sync head".to_owned()))?;
|
||||
debug!(LOGGER, "sync head {} @ {}", bh.hash(), bh.height);
|
||||
debug!("sync head {} @ {}", bh.hash(), bh.height);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -583,8 +577,8 @@ fn update_header_head(bh: &BlockHeader, ctx: &mut BlockContext) -> Result<Option
|
||||
.map_err(|e| ErrorKind::StoreErr(e, "pipe save header head".to_owned()))?;
|
||||
|
||||
debug!(
|
||||
LOGGER,
|
||||
"pipe: header_head updated to {} at {}", tip.last_block_h, tip.height
|
||||
"pipe: header_head updated to {} at {}",
|
||||
tip.last_block_h, tip.height
|
||||
);
|
||||
|
||||
Ok(Some(tip))
|
||||
@@ -616,7 +610,6 @@ pub fn rewind_and_apply_fork(b: &Block, ext: &mut txhashset::Extension) -> Resul
|
||||
let forked_header = ext.batch.get_block_header(¤t)?;
|
||||
|
||||
trace!(
|
||||
LOGGER,
|
||||
"rewind_and_apply_fork @ {} [{}], was @ {} [{}]",
|
||||
forked_header.height,
|
||||
forked_header.hash(),
|
||||
@@ -627,11 +620,7 @@ pub fn rewind_and_apply_fork(b: &Block, ext: &mut txhashset::Extension) -> Resul
|
||||
// Rewind the txhashset state back to the block where we forked from the most work chain.
|
||||
ext.rewind(&forked_header)?;
|
||||
|
||||
trace!(
|
||||
LOGGER,
|
||||
"rewind_and_apply_fork: blocks on fork: {:?}",
|
||||
fork_hashes,
|
||||
);
|
||||
trace!("rewind_and_apply_fork: blocks on fork: {:?}", fork_hashes,);
|
||||
|
||||
// Now re-apply all blocks on this fork.
|
||||
for (_, h) in fork_hashes {
|
||||
|
||||
Reference in New Issue
Block a user