diff --git a/main.cpp b/main.cpp index a1b94a7..55b3607 100755 --- a/main.cpp +++ b/main.cpp @@ -60,12 +60,21 @@ if (*help_opt) auto monero_log_level = *(opts.get_option("monero-log-level")); +auto verbose_level = + *(opts.get_option("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("do-not-relay"); auto testnet_opt = opts.get_option("testnet"); auto stagenet_opt = opts.get_option("stagenet"); diff --git a/src/CmdLineOptions.cpp b/src/CmdLineOptions.cpp index 68bf317..d607238 100755 --- a/src/CmdLineOptions.cpp +++ b/src/CmdLineOptions.cpp @@ -40,6 +40,9 @@ namespace xmreg ("monero-log-level,m", value() ->default_value(1), "Monero log level 1-4, default is 1.") + ("verbose,v", value() + ->default_value(0), + "OpenMonero log verbose level 0-4, default is 0.") ("log-file,l", value() ->default_value("./openmonero.log"), "Name and path to log file. -l \"\" to disable log file."); diff --git a/src/CurrentBlockchainStatus.cpp b/src/CurrentBlockchainStatus.cpp index 4c3a63d..3086d40 100755 --- a/src/CurrentBlockchainStatus.cpp +++ b/src/CurrentBlockchainStatus.cpp @@ -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 lck (searching_threads_map_mtx); + return searching_threads.size(); +} + void CurrentBlockchainStatus::clean_search_thread_map() { diff --git a/src/CurrentBlockchainStatus.h b/src/CurrentBlockchainStatus.h index 4517b68..31f7364 100755 --- a/src/CurrentBlockchainStatus.h +++ b/src/CurrentBlockchainStatus.h @@ -262,6 +262,9 @@ public: virtual void clean_search_thread_map(); + virtual size_t + thread_map_size(); + virtual void stop_search_threads(); diff --git a/src/TxSearch.cpp b/src/TxSearch.cpp index 0ff6783..b1a1b31 100755 --- a/src/TxSearch.cpp +++ b/src/TxSearch.cpp @@ -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 txs_hashes_from_blocks; vector 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 inputs_found; diff --git a/src/om_log.h b/src/om_log.h index 3d12bc6..812d70f 100755 --- a/src/om_log.h +++ b/src/om_log.h @@ -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