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
+14 -17
View File
@@ -36,8 +36,8 @@ use libwallet::types::{
WalletClient, WalletInfo,
};
use libwallet::{Error, ErrorKind};
use util;
use util::secp::pedersen;
use util::{self, LOGGER};
/// Wrapper around internal API functions, containing a reference to
/// the wallet/keychain that they're acting upon
@@ -188,7 +188,6 @@ where
Ok(s) => s,
Err(e) => {
error!(
LOGGER,
"Communication with receiver failed on SenderInitiation send. Aborting transaction {:?}",
e,
);
@@ -321,11 +320,10 @@ where
};
let res = client.post_tx(&TxWrapper { tx_hex: tx_hex }, fluff);
if let Err(e) = res {
error!(LOGGER, "api: post_tx: failed with error: {}", e);
error!("api: post_tx: failed with error: {}", e);
Err(e)
} else {
debug!(
LOGGER,
"api: post_tx: successfully posted tx: {}, fluff? {}",
slate.tx.hash(),
fluff
@@ -351,14 +349,14 @@ where
};
if confirmed {
warn!(
LOGGER,
"api: dump_stored_tx: transaction at {} is already confirmed.", tx_id
"api: dump_stored_tx: transaction at {} is already confirmed.",
tx_id
);
}
if tx_hex.is_none() {
error!(
LOGGER,
"api: dump_stored_tx: completed transaction at {} does not exist.", tx_id
"api: dump_stored_tx: completed transaction at {} does not exist.",
tx_id
);
return Err(ErrorKind::TransactionBuildingNotCompleted(tx_id))?;
}
@@ -386,15 +384,15 @@ where
};
if confirmed {
error!(
LOGGER,
"api: repost_tx: transaction at {} is confirmed. NOT resending.", tx_id
"api: repost_tx: transaction at {} is confirmed. NOT resending.",
tx_id
);
return Err(ErrorKind::TransactionAlreadyConfirmed)?;
}
if tx_hex.is_none() {
error!(
LOGGER,
"api: repost_tx: completed transaction at {} does not exist.", tx_id
"api: repost_tx: completed transaction at {} does not exist.",
tx_id
);
return Err(ErrorKind::TransactionBuildingNotCompleted(tx_id))?;
}
@@ -406,12 +404,12 @@ where
fluff,
);
if let Err(e) = res {
error!(LOGGER, "api: repost_tx: failed with error: {}", e);
error!("api: repost_tx: failed with error: {}", e);
Err(e)
} else {
debug!(
LOGGER,
"api: repost_tx: successfully posted tx at: {}, fluff? {}", tx_id, fluff
"api: repost_tx: successfully posted tx at: {}, fluff? {}",
tx_id, fluff
);
Ok(())
}
@@ -541,11 +539,10 @@ where
w.close()?;
if let Err(e) = res {
error!(LOGGER, "api: receive_tx: failed with error: {}", e);
error!("api: receive_tx: failed with error: {}", e);
Err(e)
} else {
debug!(
LOGGER,
"api: receive_tx: successfully received tx: {}",
slate.tx.hash()
);