Implementation ~copy paste~ inspired by https://github.com/bitcoin/bitcoin/blob/57b34599b2deb179ff1bd97ffeab91ec9f904d85/src/leveldb/util/posix_logger.h#L28
ping @laanwj
Implementation ~copy paste~ inspired by https://github.com/bitcoin/bitcoin/blob/57b34599b2deb179ff1bd97ffeab91ec9f904d85/src/leveldb/util/posix_logger.h#L28
ping @laanwj
40 | + 41 | + // Print the message 42 | + if (p < limit) { 43 | + va_list backup_ap; 44 | + va_copy(backup_ap, ap); 45 | + p += vsnprintf(p, limit - p, format, backup_ap);
nit: I'd prefer not to use vsnprintf here. We've purged this from the code when introducing tinyformat. Wonder if we can do something based on our strprintf. Though bridging between C varargs and C++ is likely going to be difficult, and this solution as-taken-from LevelDB should be fine. It's just fairly ugly code and should not be taken as a hint to contributors that using system v?s?n?printf is okay in other places.
Maybe just add a comment in that regard, mentioning where the code comes from and why and explaining the above.
Added some comments about the ugly vsprintf. Bridging varargs to use strprintf is difficult and error prone. I do not think it is worth it.
44 | @@ -44,6 +45,11 @@ const std::vector<unsigned char>& GetObfuscateKey(const CDBWrapper &w); 45 | 46 | }; 47 | 48 | +class CBitcoinLogger : public leveldb::Logger {
CBitcoinLevelDBLogger maybe? The name is too general otherwise, we should reserve this class name for ourselves.
Renamed. Can Travis be restarted ? I do not think the error is related to this PR.
44 | @@ -44,6 +45,11 @@ const std::vector<unsigned char>& GetObfuscateKey(const CDBWrapper &w); 45 | 46 | }; 47 | 48 | +class CBitcoinLevelDBLogger : public leveldb::Logger {
Why is this class in the .h file? It seems to be only used internally in dbwrapper.cpp.
well, h for declaration and cpp for implementation, at least that is what I always thought. You mean just putting the class directly in the cpp ?
.h is for the externally accessible parts of a cpp file. This class doesn't need to be exposed to anything, so it can just go inside the cpp file.
Right, .h is for interface declaration. Although with C++ it's not always clear what should be part of the interface and what not (especially when tests are involved), this one could just as well be private to the .cpp.
429 | @@ -430,7 +430,7 @@ std::string HelpMessage(HelpMessageMode mode) 430 | strUsage += HelpMessageOpt("-limitdescendantsize=<n>", strprintf("Do not accept transactions if any ancestor would have more than <n> kilobytes of in-mempool descendants (default: %u).", DEFAULT_DESCENDANT_SIZE_LIMIT)); 431 | strUsage += HelpMessageOpt("-bip9params=deployment:start:end", "Use given start/end times for specified BIP9 deployment (regtest-only)"); 432 | } 433 | - std::string debugCategories = "addrman, alert, bench, cmpctblock, coindb, db, http, libevent, lock, mempool, mempoolrej, net, proxy, prune, rand, reindex, rpc, selectcoins, tor, zmq"; // Don't translate these and qt below 434 | + std::string debugCategories = "addrman, alert, bench, cmpctblock, coindb, db, http, libevent, lock, mempool, mempoolrej, net, proxy, prune, rand, reindex, rpc, selectcoins, tor, zmq, leveldb"; // Don't translate these and qt below
Please retain alphabetical ordering (leveldb should be between http and libevent)
fixed nits