mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-30 11:13:13 +00:00
Moved logging to target functions rather than caller
This commit is contained in:
parent
442bfd1600
commit
8ed0d72b12
6 changed files with 31 additions and 21 deletions
|
@ -387,7 +387,7 @@ bool Blockchain::init(BlockchainDB* db, HardFork*& hf, const bool testnet)
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
bool Blockchain::store_blockchain()
|
bool Blockchain::store_blockchain()
|
||||||
{
|
{
|
||||||
LOG_PRINT_YELLOW("Blockchain::" << __func__, LOG_LEVEL_3);
|
LOG_PRINT_L3("Blockchain::" << __func__);
|
||||||
// lock because the rpc_thread command handler also calls this
|
// lock because the rpc_thread command handler also calls this
|
||||||
CRITICAL_REGION_LOCAL(m_db->m_synchronization_lock);
|
CRITICAL_REGION_LOCAL(m_db->m_synchronization_lock);
|
||||||
|
|
||||||
|
@ -419,7 +419,8 @@ bool Blockchain::deinit()
|
||||||
{
|
{
|
||||||
LOG_PRINT_L3("Blockchain::" << __func__);
|
LOG_PRINT_L3("Blockchain::" << __func__);
|
||||||
|
|
||||||
LOG_PRINT_L0("Closing IO Service.");
|
LOG_PRINT_L1("Stopping blockchain read/write activity");
|
||||||
|
|
||||||
// stop async service
|
// stop async service
|
||||||
m_async_work_idle.reset();
|
m_async_work_idle.reset();
|
||||||
m_async_pool.join_all();
|
m_async_pool.join_all();
|
||||||
|
@ -436,14 +437,15 @@ bool Blockchain::deinit()
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_db->close();
|
m_db->close();
|
||||||
|
LOG_PRINT_L1("Local blockchain read/write activity stopped successfully");
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
LOG_PRINT_L0(std::string("Error closing blockchain db: ") + e.what());
|
LOG_ERROR(std::string("Error closing blockchain db: ") + e.what());
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
LOG_PRINT_L0("There was an issue closing/storing the blockchain, shutting down now to prevent issues!");
|
LOG_ERROR("There was an issue closing/storing the blockchain, shutting down now to prevent issues!");
|
||||||
}
|
}
|
||||||
|
|
||||||
delete m_hardfork;
|
delete m_hardfork;
|
||||||
|
|
|
@ -228,14 +228,14 @@ namespace cryptonote
|
||||||
LOG_PRINT_L1("Locking " << lock_path.string());
|
LOG_PRINT_L1("Locking " << lock_path.string());
|
||||||
if (!db_lock.try_lock())
|
if (!db_lock.try_lock())
|
||||||
{
|
{
|
||||||
LOG_PRINT_L0("Failed to lock " << lock_path.string());
|
LOG_ERROR("Failed to lock " << lock_path.string());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
catch (const std::exception &e)
|
||||||
{
|
{
|
||||||
LOG_PRINT_L0("Error trying to lock " << lock_path.string() << ": " << e.what());
|
LOG_ERROR("Error trying to lock " << lock_path.string() << ": " << e.what());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -244,6 +244,7 @@ namespace cryptonote
|
||||||
{
|
{
|
||||||
db_lock.unlock();
|
db_lock.unlock();
|
||||||
db_lock = boost::interprocess::file_lock();
|
db_lock = boost::interprocess::file_lock();
|
||||||
|
LOG_PRINT_L1("Blockchain directory successfully unlocked");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------
|
||||||
|
@ -387,7 +388,7 @@ namespace cryptonote
|
||||||
}
|
}
|
||||||
catch (const DB_ERROR& e)
|
catch (const DB_ERROR& e)
|
||||||
{
|
{
|
||||||
LOG_PRINT_L0("Error opening database: " << e.what());
|
LOG_ERROR("Error opening database: " << e.what());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -432,16 +433,12 @@ namespace cryptonote
|
||||||
bool core::deinit()
|
bool core::deinit()
|
||||||
{
|
{
|
||||||
m_miner.stop();
|
m_miner.stop();
|
||||||
LOG_PRINT_L2("Mining Stopped");
|
|
||||||
m_mempool.deinit();
|
m_mempool.deinit();
|
||||||
LOG_PRINT_L2("Mempool Cleared");
|
|
||||||
if (!m_fast_exit)
|
if (!m_fast_exit)
|
||||||
{
|
{
|
||||||
m_blockchain_storage.deinit();
|
m_blockchain_storage.deinit();
|
||||||
LOG_PRINT_L2("Local Blockchain Read/Write Stopped");
|
|
||||||
}
|
}
|
||||||
unlock_db_directory();
|
unlock_db_directory();
|
||||||
LOG_PRINT_L2("Blockchain Directory Unlocked");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -278,7 +278,10 @@ namespace cryptonote
|
||||||
//-----------------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------------
|
||||||
bool miner::stop()
|
bool miner::stop()
|
||||||
{
|
{
|
||||||
|
LOG_PRINT_L1("Miner has received stop signal");
|
||||||
|
|
||||||
if (!is_mining())
|
if (!is_mining())
|
||||||
|
LOG_PRINT_L1("Not mining - nothing to stop" );
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
send_stop_signal();
|
send_stop_signal();
|
||||||
|
|
|
@ -689,7 +689,7 @@ namespace cryptonote
|
||||||
bool res = tools::unserialize_obj_from_file(*this, state_file_path);
|
bool res = tools::unserialize_obj_from_file(*this, state_file_path);
|
||||||
if(!res)
|
if(!res)
|
||||||
{
|
{
|
||||||
LOG_PRINT_L1("Failed to load memory pool from file " << state_file_path);
|
LOG_ERROR("Failed to load memory pool from file " << state_file_path);
|
||||||
|
|
||||||
m_transactions.clear();
|
m_transactions.clear();
|
||||||
m_txs_by_fee.clear();
|
m_txs_by_fee.clear();
|
||||||
|
@ -710,12 +710,15 @@ namespace cryptonote
|
||||||
//TODO: investigate whether only ever returning true is correct
|
//TODO: investigate whether only ever returning true is correct
|
||||||
bool tx_memory_pool::deinit()
|
bool tx_memory_pool::deinit()
|
||||||
{
|
{
|
||||||
|
LOG_PRINT_L1("Received signal to deactivate memory pool store");
|
||||||
|
|
||||||
if (m_config_folder.empty())
|
if (m_config_folder.empty())
|
||||||
|
LOG_PRINT_L1("Memory pool store already empty");
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!tools::create_directories_if_necessary(m_config_folder))
|
if (!tools::create_directories_if_necessary(m_config_folder))
|
||||||
{
|
{
|
||||||
LOG_PRINT_L1("Failed to create data directory: " << m_config_folder);
|
LOG_ERROR("Failed to create memory pool data directory: " << m_config_folder);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -723,8 +726,14 @@ namespace cryptonote
|
||||||
bool res = tools::serialize_obj_to_file(*this, state_file_path);
|
bool res = tools::serialize_obj_to_file(*this, state_file_path);
|
||||||
if(!res)
|
if(!res)
|
||||||
{
|
{
|
||||||
LOG_PRINT_L1("Failed to serialize memory pool to file " << state_file_path);
|
LOG_ERROR("Failed to serialize memory pool to file " << state_file_path);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG_PRINT_L1("Memory pool store deactivated successfully");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,8 +75,6 @@ namespace cryptonote
|
||||||
template<class t_core>
|
template<class t_core>
|
||||||
bool t_cryptonote_protocol_handler<t_core>::deinit()
|
bool t_cryptonote_protocol_handler<t_core>::deinit()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -69,12 +69,13 @@ public:
|
||||||
|
|
||||||
~t_protocol()
|
~t_protocol()
|
||||||
{
|
{
|
||||||
LOG_PRINT_L0("Deinitializing cryptonote_protocol...");
|
LOG_PRINT_L0("Stopping cryptonote protocol...");
|
||||||
try {
|
try {
|
||||||
m_protocol.deinit();
|
m_protocol.deinit();
|
||||||
m_protocol.set_p2p_endpoint(nullptr);
|
m_protocol.set_p2p_endpoint(nullptr);
|
||||||
|
LOG_PRINT_L0("Cryptonote protocol stopped successfully");
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
LOG_PRINT_L0("Failed to deinitialize protocol...");
|
LOG_ERROR("Failed to stop cryptonote protocol!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue