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:
+11
-10
@@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
#[macro_use]
|
||||
extern crate slog;
|
||||
extern crate log;
|
||||
|
||||
extern crate grin_api as api;
|
||||
extern crate grin_chain as chain;
|
||||
@@ -33,12 +33,13 @@ use util::Mutex;
|
||||
use core::global::{self, ChainTypes};
|
||||
|
||||
use framework::{LocalServerContainer, LocalServerContainerConfig};
|
||||
use util::{init_test_logger, LOGGER};
|
||||
use util::init_test_logger;
|
||||
|
||||
#[test]
|
||||
fn simple_server_wallet() {
|
||||
init_test_logger();
|
||||
info!(LOGGER, "starting simple_server_wallet");
|
||||
info!("starting simple_server_wallet");
|
||||
let test_name_dir = "test_servers";
|
||||
core::global::set_mining_mode(core::global::ChainTypes::AutomatedTesting);
|
||||
|
||||
// Run a separate coinbase wallet for coinbase transactions
|
||||
@@ -82,11 +83,11 @@ fn simple_server_wallet() {
|
||||
let base_addr = server_config.base_addr;
|
||||
let api_server_port = server_config.api_server_port;
|
||||
|
||||
warn!(LOGGER, "Testing chain handler");
|
||||
warn!("Testing chain handler");
|
||||
let tip = get_tip(&base_addr, api_server_port);
|
||||
assert!(tip.is_ok());
|
||||
|
||||
warn!(LOGGER, "Testing status handler");
|
||||
warn!("Testing status handler");
|
||||
let status = get_status(&base_addr, api_server_port);
|
||||
assert!(status.is_ok());
|
||||
|
||||
@@ -97,7 +98,7 @@ fn simple_server_wallet() {
|
||||
current_tip = get_tip(&base_addr, api_server_port).unwrap();
|
||||
}
|
||||
|
||||
warn!(LOGGER, "Testing block handler");
|
||||
warn!("Testing block handler");
|
||||
let last_block_by_height = get_block_by_height(&base_addr, api_server_port, current_tip.height);
|
||||
assert!(last_block_by_height.is_ok());
|
||||
let last_block_by_height_compact =
|
||||
@@ -111,7 +112,7 @@ fn simple_server_wallet() {
|
||||
get_block_by_hash_compact(&base_addr, api_server_port, &block_hash);
|
||||
assert!(last_block_by_hash_compact.is_ok());
|
||||
|
||||
warn!(LOGGER, "Testing chain output handler");
|
||||
warn!("Testing chain output handler");
|
||||
let start_height = 0;
|
||||
let end_height = current_tip.height;
|
||||
let outputs_by_height =
|
||||
@@ -123,7 +124,7 @@ fn simple_server_wallet() {
|
||||
let outputs_by_ids2 = get_outputs_by_ids2(&base_addr, api_server_port, ids.clone());
|
||||
assert!(outputs_by_ids2.is_ok());
|
||||
|
||||
warn!(LOGGER, "Testing txhashset handler");
|
||||
warn!("Testing txhashset handler");
|
||||
let roots = get_txhashset_roots(&base_addr, api_server_port);
|
||||
assert!(roots.is_ok());
|
||||
let last_10_outputs = get_txhashset_lastoutputs(&base_addr, api_server_port, 0);
|
||||
@@ -147,7 +148,7 @@ fn simple_server_wallet() {
|
||||
#[test]
|
||||
fn test_p2p() {
|
||||
init_test_logger();
|
||||
info!(LOGGER, "starting test_p2p");
|
||||
info!("starting test_p2p");
|
||||
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
||||
|
||||
let test_name_dir = "test_servers";
|
||||
@@ -188,7 +189,7 @@ fn test_p2p() {
|
||||
thread::sleep(time::Duration::from_millis(2000));
|
||||
|
||||
// Starting tests
|
||||
warn!(LOGGER, "Starting P2P Tests");
|
||||
warn!("Starting P2P Tests");
|
||||
let base_addr = server_config_one.base_addr;
|
||||
let api_server_port = server_config_one.api_server_port;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
#[macro_use]
|
||||
extern crate slog;
|
||||
extern crate log;
|
||||
|
||||
extern crate grin_api as api;
|
||||
extern crate grin_chain as chain;
|
||||
@@ -31,8 +31,6 @@ use std::sync::Arc;
|
||||
use std::{thread, time};
|
||||
use util::Mutex;
|
||||
|
||||
use util::LOGGER;
|
||||
|
||||
/// Start 1 node mining, 1 non mining node and two wallets.
|
||||
/// Then send a transaction from one wallet to another and propagate it a stem
|
||||
/// transaction but without stem relay and check if the transaction is still
|
||||
@@ -136,7 +134,7 @@ fn test_dandelion_timeout() {
|
||||
LocalServerContainer::get_wallet_info(&coinbase_wallet_config, &coinbase_seed);
|
||||
}
|
||||
|
||||
warn!(LOGGER, "Sending 50 Grins to recipient wallet");
|
||||
warn!("Sending 50 Grins to recipient wallet");
|
||||
|
||||
// Sending stem transaction
|
||||
LocalServerContainer::send_amount_to(
|
||||
|
||||
@@ -21,7 +21,7 @@ extern crate grin_servers as servers;
|
||||
extern crate grin_util as util;
|
||||
extern crate grin_wallet as wallet;
|
||||
#[macro_use]
|
||||
extern crate slog;
|
||||
extern crate log;
|
||||
|
||||
mod framework;
|
||||
|
||||
@@ -34,7 +34,6 @@ use util::Mutex;
|
||||
use core::core::hash::Hashed;
|
||||
use core::global::{self, ChainTypes};
|
||||
|
||||
use util::LOGGER;
|
||||
use wallet::controller;
|
||||
use wallet::libtx::slate::Slate;
|
||||
use wallet::libwallet::types::{WalletBackend, WalletInst};
|
||||
@@ -243,7 +242,7 @@ fn simulate_block_propagation() {
|
||||
thread::sleep(time::Duration::from_millis(1_000));
|
||||
time_spent += 1;
|
||||
if time_spent >= 30 {
|
||||
info!(LOGGER, "simulate_block_propagation - fail on timeout",);
|
||||
info!("simulate_block_propagation - fail on timeout",);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -285,7 +284,6 @@ fn simulate_full_sync() {
|
||||
// Get the current header from s1.
|
||||
let s1_header = s1.chain.head_header().unwrap();
|
||||
info!(
|
||||
LOGGER,
|
||||
"simulate_full_sync - s1 header head: {} at {}",
|
||||
s1_header.hash(),
|
||||
s1_header.height
|
||||
@@ -298,7 +296,6 @@ fn simulate_full_sync() {
|
||||
time_spent += 1;
|
||||
if time_spent >= 30 {
|
||||
info!(
|
||||
LOGGER,
|
||||
"sync fail. s2.head().height: {}, s1_header.height: {}",
|
||||
s2.head().height,
|
||||
s1_header.height
|
||||
@@ -356,7 +353,6 @@ fn simulate_fast_sync() {
|
||||
total_wait += 1;
|
||||
if total_wait >= 30 {
|
||||
error!(
|
||||
LOGGER,
|
||||
"simulate_fast_sync test fail on timeout! s2 height: {}, s1 height: {}",
|
||||
s2.head().height,
|
||||
s1_header.height,
|
||||
|
||||
+11
-12
@@ -23,7 +23,7 @@ extern crate grin_wallet as wallet;
|
||||
extern crate bufstream;
|
||||
extern crate serde_json;
|
||||
#[macro_use]
|
||||
extern crate slog;
|
||||
extern crate log;
|
||||
|
||||
mod framework;
|
||||
|
||||
@@ -38,7 +38,6 @@ use std::sync::Arc;
|
||||
use std::{thread, time};
|
||||
|
||||
use core::global::{self, ChainTypes};
|
||||
use util::LOGGER;
|
||||
|
||||
use framework::{config, stratum_config};
|
||||
|
||||
@@ -77,7 +76,7 @@ fn basic_stratum_server() {
|
||||
}
|
||||
// As this stream falls out of scope it will be disconnected
|
||||
}
|
||||
info!(LOGGER, "stratum server connected");
|
||||
info!("stratum server connected");
|
||||
|
||||
// Create a few new worker connections
|
||||
let mut workers = vec![];
|
||||
@@ -89,7 +88,7 @@ fn basic_stratum_server() {
|
||||
workers.push(stream);
|
||||
}
|
||||
assert!(workers.len() == 5);
|
||||
info!(LOGGER, "workers length verification ok");
|
||||
info!("workers length verification ok");
|
||||
|
||||
// Simulate a worker lost connection
|
||||
workers.remove(4);
|
||||
@@ -118,7 +117,7 @@ fn basic_stratum_server() {
|
||||
assert!(false);
|
||||
}
|
||||
}
|
||||
info!(LOGGER, "a few stratum JSONRpc commands verification ok");
|
||||
info!("a few stratum JSONRpc commands verification ok");
|
||||
|
||||
// keepalive - expected "ok" result
|
||||
let mut response = String::new();
|
||||
@@ -129,7 +128,7 @@ fn basic_stratum_server() {
|
||||
thread::sleep(time::Duration::from_secs(1)); // Wait for the server to reply
|
||||
let _st = workers[2].read_line(&mut response);
|
||||
assert_eq!(response.as_str(), ok_resp);
|
||||
info!(LOGGER, "keepalive test ok");
|
||||
info!("keepalive test ok");
|
||||
|
||||
// "doesnotexist" - error expected
|
||||
let mut response = String::new();
|
||||
@@ -140,7 +139,7 @@ fn basic_stratum_server() {
|
||||
thread::sleep(time::Duration::from_secs(1)); // Wait for the server to reply
|
||||
let _st = workers[3].read_line(&mut response);
|
||||
assert_eq!(response.as_str(), ok_resp);
|
||||
info!(LOGGER, "worker doesnotexist test ok");
|
||||
info!("worker doesnotexist test ok");
|
||||
|
||||
// Verify stratum server and worker stats
|
||||
let stats = s.get_server_stats().unwrap();
|
||||
@@ -148,18 +147,18 @@ fn basic_stratum_server() {
|
||||
assert_eq!(stats.stratum_stats.num_workers, 4); // 5 - 1 = 4
|
||||
assert_eq!(stats.stratum_stats.worker_stats[5].is_connected, false); // worker was removed
|
||||
assert_eq!(stats.stratum_stats.worker_stats[1].is_connected, true);
|
||||
info!(LOGGER, "stratum server and worker stats verification ok");
|
||||
info!("stratum server and worker stats verification ok");
|
||||
|
||||
// Start mining blocks
|
||||
let stop = Arc::new(AtomicBool::new(false));
|
||||
s.start_test_miner(None, stop.clone());
|
||||
info!(LOGGER, "test miner started");
|
||||
info!("test miner started");
|
||||
|
||||
// This test is supposed to complete in 3 seconds,
|
||||
// so let's set a timeout on 10s to avoid infinite waiting happened in Travis-CI.
|
||||
let _handler = thread::spawn(|| {
|
||||
thread::sleep(time::Duration::from_secs(10));
|
||||
error!(LOGGER, "basic_stratum_server test fail on timeout!");
|
||||
error!("basic_stratum_server test fail on timeout!");
|
||||
thread::sleep(time::Duration::from_millis(100));
|
||||
process::exit(1);
|
||||
});
|
||||
@@ -177,12 +176,12 @@ fn basic_stratum_server() {
|
||||
let _st = workers[2].read_line(&mut jobtemplate);
|
||||
let job_template: Value = serde_json::from_str(&jobtemplate).unwrap();
|
||||
assert_eq!(job_template["method"], expected);
|
||||
info!(LOGGER, "blocks broadcasting to workers test ok");
|
||||
info!("blocks broadcasting to workers test ok");
|
||||
|
||||
// Verify stratum server and worker stats
|
||||
let stats = s.get_server_stats().unwrap();
|
||||
assert_eq!(stats.stratum_stats.num_workers, 3); // 5 - 2 = 3
|
||||
assert_eq!(stats.stratum_stats.worker_stats[2].is_connected, false); // worker was removed
|
||||
assert_ne!(stats.stratum_stats.block_height, 1);
|
||||
info!(LOGGER, "basic_stratum_server test done and ok.");
|
||||
info!("basic_stratum_server test done and ok.");
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
#[macro_use]
|
||||
extern crate slog;
|
||||
extern crate log;
|
||||
|
||||
extern crate grin_api as api;
|
||||
extern crate grin_chain as chain;
|
||||
@@ -31,8 +31,6 @@ use std::sync::Arc;
|
||||
use std::{thread, time};
|
||||
use util::Mutex;
|
||||
|
||||
use util::LOGGER;
|
||||
|
||||
/// Start 1 node mining and two wallets, then send a few
|
||||
/// transactions from one to the other
|
||||
#[ignore]
|
||||
@@ -105,7 +103,7 @@ fn basic_wallet_transactions() {
|
||||
coinbase_info =
|
||||
LocalServerContainer::get_wallet_info(&coinbase_wallet_config, &coinbase_seed);
|
||||
}
|
||||
warn!(LOGGER, "Sending 50 Grins to recipient wallet");
|
||||
warn!("Sending 50 Grins to recipient wallet");
|
||||
LocalServerContainer::send_amount_to(
|
||||
&coinbase_wallet_config,
|
||||
"50.00",
|
||||
@@ -125,10 +123,7 @@ fn basic_wallet_transactions() {
|
||||
println!("Recipient wallet info: {:?}", recipient_info);
|
||||
assert!(recipient_info.amount_currently_spendable == 50000000000);
|
||||
|
||||
warn!(
|
||||
LOGGER,
|
||||
"Sending many small transactions to recipient wallet"
|
||||
);
|
||||
warn!("Sending many small transactions to recipient wallet");
|
||||
for _i in 0..10 {
|
||||
LocalServerContainer::send_amount_to(
|
||||
&coinbase_wallet_config,
|
||||
|
||||
Reference in New Issue
Block a user