verbose log levels added

pull/155/head
moneroexamples 5 years ago
parent 8dcc7506f1
commit f9887e6f57

@ -60,12 +60,21 @@ if (*help_opt)
auto monero_log_level =
*(opts.get_option<size_t>("monero-log-level"));
auto verbose_level =
*(opts.get_option<size_t>("verbose"));
if (monero_log_level < 1 || monero_log_level > 4)
{
cerr << "monero-log-level,m option must be between 1 and 4!\n";
return EXIT_SUCCESS;
}
if (verbose_level < 0 || verbose_level > 4)
{
cerr << "verbose,v option must be between 0 and 4!\n";
return EXIT_SUCCESS;
}
// setup monero logger
mlog_configure(mlog_get_default_log_path(""), true);
mlog_set_log(std::to_string(monero_log_level).c_str());
@ -93,10 +102,15 @@ defaultConf.setGlobally(el::ConfigurationType::Format,
"%datetime [%levshort,%logger,%fbase:%func:%line]"
" %msg");
el::Loggers::setVerboseLevel(verbose_level);
el::Loggers::reconfigureLogger(OPENMONERO_LOG_CATEGORY, defaultConf);
OMINFO << "OpenMonero is starting";
if (verbose_level > 0)
OMINFO << "Using verbose log level to: " << verbose_level;
auto do_not_relay_opt = opts.get_option<bool>("do-not-relay");
auto testnet_opt = opts.get_option<bool>("testnet");
auto stagenet_opt = opts.get_option<bool>("stagenet");

@ -40,6 +40,9 @@ namespace xmreg
("monero-log-level,m", value<size_t>()
->default_value(1),
"Monero log level 1-4, default is 1.")
("verbose,v", value<size_t>()
->default_value(0),
"OpenMonero log verbose level 0-4, default is 0.")
("log-file,l", value<string>()
->default_value("./openmonero.log"),
"Name and path to log file. -l \"\" to disable log file.");

@ -46,15 +46,16 @@ CurrentBlockchainStatus::monitor_blockchain()
break;
}
OMINFO << "PoolQueue size: "
<< TP::DefaultThreadPool::queueSize();
OMVLOG1 << "PoolQueue size: "
<< TP::DefaultThreadPool::queueSize();
update_current_blockchain_height();
read_mempool();
OMINFO << "Current blockchain height: " << current_height
<< ", no of mempool txs: " << mempool_txs.size();
<< ", pool size: " << mempool_txs.size() << " txs"
<< ", no of TxSearch threads: " << thread_map_size();
clean_search_thread_map();
@ -1122,6 +1123,13 @@ CurrentBlockchainStatus::get_search_thread(string const& acc_address)
return searching_threads.find(acc_address)->second.get_functor();
}
size_t
CurrentBlockchainStatus::thread_map_size()
{
std::lock_guard<std::mutex> lck (searching_threads_map_mtx);
return searching_threads.size();
}
void
CurrentBlockchainStatus::clean_search_thread_map()
{

@ -262,6 +262,9 @@ public:
virtual void
clean_search_thread_map();
virtual size_t
thread_map_size();
virtual void
stop_search_threads();

@ -103,16 +103,14 @@ if (blocks.empty())
if (h1 <= h2)
{
OMERROR << address_prefix
<< ": cant get blocks from " << h1
OMERROR << address_prefix << ": cant get blocks from " << h1
<< " to " << h2;
stop();
}
else
{
OMINFO << address_prefix
<< ": waiting for new block. "
"Last scanned was " << h2;
OMVLOG1 << address_prefix << ": waiting for new block. "
<< "Last scanned was " << h2;
}
std::this_thread::sleep_for(
@ -146,10 +144,10 @@ if (blocks.empty())
continue;
}
OMINFO << address_prefix + ": analyzing "
<< blocks.size() << " blocks from "
<< h1 << " to " << h2
<< " out of " << last_block_height << " blocks";
OMVLOG2 << address_prefix + ": analyzing "
<< blocks.size() << " blocks from "
<< h1 << " to " << h2
<< " out of " << last_block_height << " blocks";
vector<crypto::hash> txs_hashes_from_blocks;
vector<transaction> txs_in_blocks;
@ -291,15 +289,13 @@ for (auto const& tx_tuple: txs_data)
if (!current_bc_status->tx_exist(tx_hash, blockchain_tx_id))
{
OMERROR << "Tx " << tx_hash_str
<< " not found in blockchain !";
<< " not found in blockchain!";
throw TxSearchException("Cant get tx from blockchain: "
+ tx_hash_str);
}
OMINFO << address_prefix
+ ": found some outputs in block "
<< blk_height << ", tx: "
<< tx_hash_str;
OMVLOG1 << address_prefix + ": found some outputs in block "
<< blk_height << ", tx: " << tx_hash_str;
XmrTransaction tx_data;
@ -467,11 +463,9 @@ for (auto const& tx_tuple: txs_data)
}
}
OMINFO << address_prefix
+ ": found some possible "
"inputs in block "
<< blk_height << ", tx: "
<< tx_hash_str;
OMVLOG1 << address_prefix + ": found some possible "
<< "inputs in block " << blk_height << ", tx: "
<< tx_hash_str;
vector<XmrInput> inputs_found;

@ -7,9 +7,14 @@
#define OMWARN CLOG(WARNING, OPENMONERO_LOG_CATEGORY)
#define OMERROR CLOG(ERROR, OPENMONERO_LOG_CATEGORY)
#define OMVLOG1 CVLOG(1, OPENMONERO_LOG_CATEGORY)
#define OMVLOG2 CVLOG(2, OPENMONERO_LOG_CATEGORY)
#define OMVLOG3 CVLOG(3, OPENMONERO_LOG_CATEGORY)
#define OMVLOG4 CVLOG(4, OPENMONERO_LOG_CATEGORY)
#define OMINFO_IF(cond) CLOG_IF(cond, INFO, OPENMONERO_LOG_CATEGORY)
#define OMWARN_IF(cond) CLOG_IF(cond, WARNING, OPENMONERO_LOG_CATEGORY)
#define OMERROR_IF(cond) CLOG_IF(cond, ERROR, OPENMONERO_LOG_CATEGORY)
#endif // OM_LOG_H
#endif // OM_LOG_H

Loading…
Cancel
Save