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
+2 -3
View File
@@ -20,7 +20,7 @@ extern crate grin_util as util;
extern crate grin_wallet as wallet;
extern crate rand;
#[macro_use]
extern crate slog;
extern crate log;
extern crate chrono;
extern crate serde;
extern crate uuid;
@@ -35,7 +35,6 @@ use std::time::Duration;
use core::global;
use core::global::ChainTypes;
use keychain::{ExtKeychain, Keychain};
use util::LOGGER;
use wallet::libwallet;
fn clean_output_dir(test_dir: &str) {
@@ -69,7 +68,7 @@ fn accounts_test_impl(test_dir: &str) -> Result<(), libwallet::Error> {
// Set the wallet proxy listener running
thread::spawn(move || {
if let Err(e) = wallet_proxy.run() {
error!(LOGGER, "Wallet Proxy error: {}", e);
error!("Wallet Proxy error: {}", e);
}
});
+5 -9
View File
@@ -28,8 +28,8 @@ use util::{Mutex, RwLock};
use common::api;
use common::serde_json;
use store;
use util;
use util::secp::pedersen::Commitment;
use util::{self, LOGGER};
use common::failure::ResultExt;
@@ -146,7 +146,7 @@ where
thread::sleep(Duration::from_millis(10));
// read queue
let m = self.rx.recv().unwrap();
trace!(LOGGER, "Wallet Client Proxy Received: {:?}", m);
trace!("Wallet Client Proxy Received: {:?}", m);
let resp = match m.method.as_ref() {
"get_chain_height" => self.get_chain_height(m)?,
"get_outputs_from_node" => self.get_outputs_from_node(m)?,
@@ -345,7 +345,7 @@ impl WalletClient for LocalWalletClient {
}
let r = self.rx.lock();
let m = r.recv().unwrap();
trace!(LOGGER, "Received send_tx_slate response: {:?}", m.clone());
trace!("Received send_tx_slate response: {:?}", m.clone());
Ok(
serde_json::from_str(&m.body).context(libwallet::ErrorKind::ClientCallback(
"Parsing send_tx_slate response",
@@ -369,7 +369,7 @@ impl WalletClient for LocalWalletClient {
}
let r = self.rx.lock();
let m = r.recv().unwrap();
trace!(LOGGER, "Received post_tx response: {:?}", m.clone());
trace!("Received post_tx response: {:?}", m.clone());
Ok(())
}
@@ -389,11 +389,7 @@ impl WalletClient for LocalWalletClient {
}
let r = self.rx.lock();
let m = r.recv().unwrap();
trace!(
LOGGER,
"Received get_chain_height response: {:?}",
m.clone()
);
trace!("Received get_chain_height response: {:?}", m.clone());
Ok(m.body
.parse::<u64>()
.context(libwallet::ErrorKind::ClientCallback(
+4 -5
View File
@@ -20,7 +20,7 @@ extern crate grin_util as util;
extern crate grin_wallet as wallet;
extern crate rand;
#[macro_use]
extern crate slog;
extern crate log;
extern crate chrono;
extern crate serde;
extern crate uuid;
@@ -35,7 +35,6 @@ use std::time::Duration;
use core::global;
use core::global::ChainTypes;
use keychain::{ExtKeychain, Identifier, Keychain};
use util::LOGGER;
use wallet::libtx::slate::Slate;
use wallet::libwallet;
use wallet::libwallet::types::AcctPathMapping;
@@ -67,7 +66,7 @@ fn restore_wallet(base_dir: &str, wallet_dir: &str) -> Result<(), libwallet::Err
// Set the wallet proxy listener running
thread::spawn(move || {
if let Err(e) = wallet_proxy.run() {
error!(LOGGER, "Wallet Proxy error: {}", e);
error!("Wallet Proxy error: {}", e);
}
});
@@ -121,7 +120,7 @@ fn compare_wallet_restore(
// Set the wallet proxy listener running
thread::spawn(move || {
if let Err(e) = wallet_proxy.run() {
error!(LOGGER, "Wallet Proxy error: {}", e);
error!("Wallet Proxy error: {}", e);
}
});
@@ -218,7 +217,7 @@ fn setup_restore(test_dir: &str) -> Result<(), libwallet::Error> {
// Set the wallet proxy listener running
thread::spawn(move || {
if let Err(e) = wallet_proxy.run() {
error!(LOGGER, "Wallet Proxy error: {}", e);
error!("Wallet Proxy error: {}", e);
}
});
+6 -11
View File
@@ -20,7 +20,7 @@ extern crate grin_util as util;
extern crate grin_wallet as wallet;
extern crate rand;
#[macro_use]
extern crate slog;
extern crate log;
extern crate chrono;
extern crate serde;
extern crate uuid;
@@ -35,7 +35,6 @@ use std::time::Duration;
use core::global;
use core::global::ChainTypes;
use keychain::ExtKeychain;
use util::LOGGER;
use wallet::libtx::slate::Slate;
use wallet::libwallet;
use wallet::libwallet::types::OutputStatus;
@@ -73,7 +72,7 @@ fn basic_transaction_api(test_dir: &str) -> Result<(), libwallet::Error> {
// Set the wallet proxy listener running
thread::spawn(move || {
if let Err(e) = wallet_proxy.run() {
error!(LOGGER, "Wallet Proxy error: {}", e);
error!("Wallet Proxy error: {}", e);
}
});
@@ -87,10 +86,8 @@ fn basic_transaction_api(test_dir: &str) -> Result<(), libwallet::Error> {
wallet::controller::owner_single_use(wallet1.clone(), |api| {
let (wallet1_refreshed, wallet1_info) = api.retrieve_summary_info(true)?;
debug!(
LOGGER,
"Wallet 1 Info Pre-Transaction, after {} blocks: {:?}",
wallet1_info.last_confirmed_height,
wallet1_info
wallet1_info.last_confirmed_height, wallet1_info
);
assert!(wallet1_refreshed);
assert_eq!(
@@ -166,10 +163,8 @@ fn basic_transaction_api(test_dir: &str) -> Result<(), libwallet::Error> {
wallet::controller::owner_single_use(wallet1.clone(), |api| {
let (wallet1_refreshed, wallet1_info) = api.retrieve_summary_info(true)?;
debug!(
LOGGER,
"Wallet 1 Info Post Transaction, after {} blocks: {:?}",
wallet1_info.last_confirmed_height,
wallet1_info
wallet1_info.last_confirmed_height, wallet1_info
);
let fee = wallet::libtx::tx_fee(
wallet1_info.last_confirmed_height as usize - 1 - cm as usize,
@@ -207,7 +202,7 @@ fn basic_transaction_api(test_dir: &str) -> Result<(), libwallet::Error> {
// refresh wallets and retrieve info/tests for each wallet after maturity
wallet::controller::owner_single_use(wallet1.clone(), |api| {
let (wallet1_refreshed, wallet1_info) = api.retrieve_summary_info(true)?;
debug!(LOGGER, "Wallet 1 Info: {:?}", wallet1_info);
debug!("Wallet 1 Info: {:?}", wallet1_info);
assert!(wallet1_refreshed);
assert_eq!(
wallet1_info.total,
@@ -318,7 +313,7 @@ fn tx_rollback(test_dir: &str) -> Result<(), libwallet::Error> {
// Set the wallet proxy listener running
thread::spawn(move || {
if let Err(e) = wallet_proxy.run() {
error!(LOGGER, "Wallet Proxy error: {}", e);
error!("Wallet Proxy error: {}", e);
}
});