1
0
Fork 0
forked from lthn/blockchain

simplewallet: logs msgs & levels clean up

This commit is contained in:
sowle 2022-07-23 04:32:11 +02:00
parent 765ad24b39
commit c840ba48a2
No known key found for this signature in database
GPG key ID: C07A24B2D89D49FC
4 changed files with 20 additions and 21 deletions

View file

@ -65,7 +65,7 @@ namespace epee
bool res = m_net_server.init_server(bind_port, bind_ip);
if(!res)
{
LOG_ERROR("Failed to bind server");
LOG_ERROR("Failed to bind to " << bind_ip << ":" << bind_port);
return false;
}
return true;
@ -74,14 +74,14 @@ namespace epee
bool run(size_t threads_count, bool wait = true)
{
//go to loop
LOG_PRINT("Run net_service loop( " << threads_count << " threads)...", LOG_LEVEL_0);
LOG_PRINT("Run net_service loop (" << threads_count << " threads)...", LOG_LEVEL_1);
if(!m_net_server.run_server(threads_count, wait))
{
LOG_ERROR("Failed to run net tcp server!");
}
if(wait)
LOG_PRINT("net_service loop stopped.", LOG_LEVEL_0);
LOG_PRINT("net_service loop stopped.", LOG_LEVEL_1);
return true;
}

View file

@ -2136,16 +2136,13 @@ int main(int argc, char* argv[])
log_space::log_singletone::add_logger(LOGGER_FILE, log_file_path.filename().string().c_str(), log_dir.c_str(), LOG_LEVEL_4);
message_writer(epee::log_space::console_color_white, true) << CURRENCY_NAME << " wallet v" << PROJECT_VERSION_LONG;
// if (command_line::has_arg(vm, arg_log_level))
// {
// LOG_PRINT_L0("Setting log level = " << command_line::get_arg(vm, arg_log_level));
// log_space::get_set_log_detalisation_level(true, command_line::get_arg(vm, arg_log_level));
// }
if (command_line::has_arg(vm, command_line::arg_log_level))
{
log_space::get_set_log_detalisation_level(true, command_line::get_arg(vm, command_line::arg_log_level));
LOG_PRINT_L0("Setting log level = " << command_line::get_arg(vm, command_line::arg_log_level));
message_writer(epee::log_space::console_color_white, true) << "Setting log level = " << command_line::get_arg(vm, command_line::arg_log_level);
int old_log_level = log_space::get_set_log_detalisation_level(false);
int new_log_level = command_line::get_arg(vm, command_line::arg_log_level);
log_space::get_set_log_detalisation_level(true, new_log_level);
LOG_PRINT_L0("Log level changed: " << old_log_level << " -> " << new_log_level);
message_writer(epee::log_space::console_color_white, true) << "Log level changed: " << old_log_level << " -> " << new_log_level;
}
@ -2166,7 +2163,7 @@ int main(int argc, char* argv[])
// runs wallet as RPC server
log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL, LOG_LEVEL_2);
sw->set_offline_mode(offline_mode);
LOG_PRINT_L0("Starting wallet RPC server...");
LOG_PRINT_L0("Starting in RPC server mode...");
if (!command_line::has_arg(vm, arg_wallet_file) || command_line::get_arg(vm, arg_wallet_file).empty())
{
@ -2292,7 +2289,7 @@ int main(int argc, char* argv[])
if (command_line::get_arg(vm, arg_do_pos_mining))
{
// PoS mining can be turned on only in RPC server mode, please provide --rpc-bind-port to make this
fail_msg_writer() << "PoS mining can be turned on only in RPC server mode, please provide --rpc-bind-port=PORT_NO to enable staking in simplewallet";
fail_msg_writer() << "PoS mining can only be started in RPC server mode, please use command-line option --rpc-bind-port=<PORT_NUM> along with --do-pos-mining to enable staking";
return EXIT_FAILURE;
}

View file

@ -2684,7 +2684,7 @@ void wallet2::load(const std::wstring& wallet_, const std::string& password)
{
// old WALLET_FILE_BINARY_HEADER_VERSION version means no encryption
need_to_resync = !tools::portable_unserialize_obj_from_stream(*this, data_file);
WLT_LOG_L0("Detected format: WALLET_FILE_BINARY_HEADER_VERSION_INITAL(need_to_resync=" << need_to_resync << ")");
WLT_LOG_L1("Detected format: WALLET_FILE_BINARY_HEADER_VERSION_INITAL (need_to_resync=" << need_to_resync << ")");
}
else if (wbh.m_ver == WALLET_FILE_BINARY_HEADER_VERSION_2)
{
@ -2693,7 +2693,7 @@ void wallet2::load(const std::wstring& wallet_, const std::string& password)
in.push(decrypt_filter);
in.push(data_file);
need_to_resync = !tools::portable_unserialize_obj_from_stream(*this, in);
WLT_LOG_L0("Detected format: WALLET_FILE_BINARY_HEADER_VERSION_2(need_to_resync=" << need_to_resync << ")");
WLT_LOG_L1("Detected format: WALLET_FILE_BINARY_HEADER_VERSION_2 (need_to_resync=" << need_to_resync << ")");
}
else
{
@ -2714,10 +2714,10 @@ void wallet2::load(const std::wstring& wallet_, const std::string& password)
<< ", file_size=" << m_current_wallet_file_size
<< ", blockchain_size: " << m_chain.get_blockchain_current_size()
);
WLT_LOG_L0("[LOADING]Blockchain shortener state: " << ENDL << m_chain.get_internal_state_text());
WLT_LOG_L1("[LOADING]Blockchain shortener state: " << ENDL << m_chain.get_internal_state_text());
WLT_LOG_L0("(after loading: pending_key_images: " << m_pending_key_images.size() << ", pki file elements: " << m_pending_key_images_file_container.size() << ", tx_keys: " << m_tx_keys.size() << ")");
WLT_LOG_L1("(after loading: pending_key_images: " << m_pending_key_images.size() << ", pki file elements: " << m_pending_key_images_file_container.size() << ", tx_keys: " << m_tx_keys.size() << ")");
if (need_to_resync)
{
@ -2789,7 +2789,7 @@ void wallet2::store(const std::wstring& path_to_save, const std::string& passwor
boost::uintmax_t tmp_file_size = boost::filesystem::file_size(tmp_file_path);
WLT_LOG_L0("Stored successfully to temporary file " << tmp_file_path.string() << ", file size=" << tmp_file_size);
WLT_LOG_L0("[LOADING]Blockchain shortener state: " << ENDL << m_chain.get_internal_state_text());
WLT_LOG_L1("[LOADING]Blockchain shortener state: " << ENDL << m_chain.get_internal_state_text());
// for the sake of safety perform a double-renaming: wallet file -> old tmp, new tmp -> wallet file, remove old tmp
@ -3541,7 +3541,7 @@ bool wallet2::try_mint_pos()
bool wallet2::try_mint_pos(const currency::account_public_address& miner_address)
{
mining_context ctx = AUTO_VAL_INIT(ctx);
WLT_LOG_L1("Starting PoS mining iteration");
WLT_LOG_L2("Starting PoS mining iteration");
fill_mining_context(ctx);
if (!ctx.rsp.is_pos_allowed)
{
@ -3570,7 +3570,7 @@ bool wallet2::try_mint_pos(const currency::account_public_address& miner_address
build_minted_block(ctx.sp, ctx.rsp, miner_address);
}
WLT_LOG_L0("PoS mining: " << ctx.rsp.iterations_processed << " iterations finished, status: " << ctx.rsp.status << ", used " << ctx.sp.pos_entries.size() << " entries with total amount: " << print_money_brief(pos_entries_amount));
WLT_LOG_L1("PoS mining: " << ctx.rsp.iterations_processed << " iterations finished, status: " << ctx.rsp.status << ", used " << ctx.sp.pos_entries.size() << " entries with total amount: " << print_money_brief(pos_entries_amount));
return true;
}

View file

@ -68,6 +68,8 @@ namespace tools
static const uint64_t wallet_rpc_idle_work_period_ms = 2000;
m_do_mint = do_mint;
if (m_do_mint)
LOG_PRINT_CYAN("PoS mining is ON", LOG_LEVEL_0);
if (!offline_mode)
{
@ -78,7 +80,7 @@ namespace tools
size_t blocks_fetched = 0;
bool received_money = false, ok = false;
std::atomic<bool> stop(false);
LOG_PRINT_L1("wallet RPC idle: refreshing...");
LOG_PRINT_L2("wallet RPC idle: refreshing...");
m_wallet.refresh(blocks_fetched, received_money, ok, stop);
if (stop)
{