Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change LogAcceptCategory to use uint32_t rather than sets of strings. #9424

Merged
merged 1 commit into from Apr 2, 2017
Merged

Change LogAcceptCategory to use uint32_t rather than sets of strings. #9424

merged 1 commit into from Apr 2, 2017

Conversation

gmaxwell
Copy link
Contributor

This changes the logging categories to boolean flags instead of strings.

This simplifies the acceptance testing by avoiding accessing a scoped
static thread local pointer to a thread local set of strings. It
eliminates the only use of boost::thread_specific_ptr outside of
lockorder debugging.

This change allows log entries to be directed to multiple categories
and makes it easy to change the logging flags at runtime (e.g. via
an RPC, though that isn't done by this commit.)

It also eliminates the fDebug global.

Configuration of unknown logging categories now produces a warning.

@gmaxwell
Copy link
Contributor Author

If we ever need more than 32 categories (there are 19 now) this could be trivially changed to use a uint64_t.

if ((fDebug && vInv.size() > 0) || (vInv.size() == 1))
LogPrint("net", "received getdata for: %s peer=%d\n", vInv[0].ToString(), pfrom->id);
if (vInv.size() > 0)
LogPrint(LOG_NET, "received getdata for: %s peer=%d\n", vInv[0].ToString(), pfrom->id);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prior code above struck me as somewhat brain-damaged (LogPrint() does nothing when fDebug isn't true), so this chunk could use some more review attention in case I was missing something.

src/util.h Outdated
@@ -69,15 +70,50 @@ inline std::string _(const char* psz)
void SetupEnvironment();
bool SetupNetworking();

enum LogFlags : uint32_t {
Copy link
Contributor

@rebroad rebroad Dec 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idea: Would be easier to maintain if it was possible to define LogFlags and CLogCategoryDesc in the same section...

@gmaxwell
Copy link
Contributor Author

One week, no substantive feedback. Closing.

@gmaxwell gmaxwell closed this Dec 29, 2016
@TheBlueMatt
Copy link
Contributor

Concept ACK

@paveljanik
Copy link
Contributor

Please reopen. Holidays...

Concept ACK

@rebroad
Copy link
Contributor

rebroad commented Dec 30, 2016

concept ACK

@maflcko
Copy link
Member

maflcko commented Dec 30, 2016

utACK e348647315b619e6a1d8b614554abb0747047696

@paveljanik
Copy link
Contributor

Needs rebase.

@paveljanik
Copy link
Contributor

@gmaxwell Please reopen this...

@jonasschnelli
Copy link
Contributor

Concept ACK, seems to be a great PR with serval acks. Needs rebase and reopen.

@jtimon
Copy link
Contributor

jtimon commented Mar 30, 2017

Concept ACK

@jnewbery
Copy link
Contributor

Definite concept ACK. Makes #10123 trivial.

@gmaxwell gmaxwell reopened this Mar 30, 2017
@laanwj
Copy link
Member

laanwj commented Mar 30, 2017

Concept ACK.

src/util.h Outdated
@@ -69,15 +70,50 @@ inline std::string _(const char* psz)
void SetupEnvironment();
bool SetupNetworking();

enum LogFlags : uint32_t {
LOG_NONE = 0,
LOG_NET = (1 << 0),
Copy link
Member

@laanwj laanwj Mar 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of the LOG_ prefix, I'd propose to use a scoped enum. E.g. LogFlags::NONE LogFlags::NET etc.
(defined using enum class LogFlags)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh darn, didn't see this until I'd already done the rebase. Uh, I'll look into it and put it as a commit on top for squashing. (presumably it'll be a more or less trivial change that could be reviewed separately)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

19:32 < gmaxwell> wumpus: uh. so boolean operations don't appear to exist for scoped enums. so ... I don't think I can use them without
defining a set of boolean operations for them.
19:32 < sipa> gmaxwell: eh?
19:33 < sipa> ah, scoped enums don't have an implicit conversion to int
19:34 < sipa> you can still explicitly convert them, though
19:34 < sipa> but enums are generally a bad approach for bitfields, as they're intended to be exhaustive
19:34 < gmaxwell> sipa: wumpus suggested that I change the log print thing to use a scoped enum. The original thing that inspired this
change is that rebroad wanted to do some horrible hack to do the logical equivilent of LogPrint(LOG_NET | LOG_MEMPOOL,
...). (and of course the matching also uses it as a bitfield.)
19:35 < sipa> right, a normal enum (which behaves much more like an int) may be more appropriate
19:35 < gmaxwell> well thats what I implemented.
19:37 < sipa> awesöme
19:37 < gmaxwell> in any case. I'm happy to change it to whatever. someone who has an opinion needs to tell me what to do. I think I only
need a couple casts to make the enum class stuff go, but it would be ugly to do "LogPrint(LOG_NET | LOG_MEMPOOL," later
unless we provide | for the type.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just that the LOG_ prefix is very common, so it's easy to get namespace collisions. Scoped enums avoid that, the only way any of their members can collide is when the name of the type conflicts, which would be an error in the first place.
Then again if this introduces extra C++ casting uglyness in all usages let's leave it like this...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could make it BCLOG or something like that, you're right about namespace collisions, my initial sed through to rename the LOG_ accidentally renamed some things it shouldn't.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another approach would be wrapping it in a C++ namespace (for example:

namespace bclog {
enum flags {
  NET,
  MEMPOOL,
  ...
};
}

at which point you can use bclog::NET | bclog::MEMPOOL.

Copy link
Contributor

@JeremyRubin JeremyRubin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK!

I think it would be nice if there were a semi-convenient way to add new categories without triggering a big recompile though...

src/util.h Outdated

template<typename... Args>
static inline int LogPrint(const char* category, const char* fmt, const Args&... args)
static inline int LogPrint(uint32_t category, const char* fmt, const Args&... args)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type should maybe be LogFlags for future upgrades.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that would add some type safety. It would make it more of a hassle to submit a message to more categories at once but that isn't supported now either.

@@ -56,6 +55,8 @@ extern CTranslationInterface translationInterface;
extern const char * const BITCOIN_CONF_FILENAME;
extern const char * const BITCOIN_PID_FILENAME;

extern std::atomic<uint32_t> logCategories;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this set on init single threadedly? Maybe you can drop the atomics.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect the very next logical change will be to add an RPC to turn on and off logging categories. Since all the reads are order relaxed I expect it to emit the same code as a non-atomic read (at least on x86).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've wanted this for so long! Consider this the next/2 logical change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes being able to change the debug flags at runtime (even if not the libevent and leveldb ones which are processed at startup) would be nice.

@JeremyRubin
Copy link
Contributor

Suggestion on how to make the category more extensible without triggering big recompiles:

#define LogPrint(cat, ...) _LogPrint(cat, #cat, __VA_ARGS__)
static inline int _LogPrint(uint32_t category, const char* category_str, const char* fmt, const Args&... args) {
    // ...
    if (category == LOG_USE_IDENT_NAME)
        // use the macro
    // ...
}

then from somefile.cpp

static const uint32_t LOG_SOMEFILE = LOG_USE_IDENT_NAME;
LogPrint(LOG_SOMEFILE, "...");

Copy link
Contributor

@jnewbery jnewbery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks to me like there are a couple of rebase errors here. Other than that a few nits but looks good. I've tested ab53beaf9c0d8f923f24a50b373968a8c01760d4 manually and against the extended test suite and it works.

One thing to note about the future logging RPC work: I think libevent and leveldb logging levels are set at start up, so they won't be modifiable through the RPC without some additional work. Not a problem for this PR, but something to note since it'd be easy to believe that just updating logCategories would be enough. Perhaps worth putting a comment next to the logCategories variable warning about this?

src/util.h Outdated
/** Returns a string with the supported log categories */
std::string ListLogCategories();

/** Return true of str parses as a log category and set the flags in f */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/of/if

src/util.h Outdated
std::string ListLogCategories();

/** Return true of str parses as a log category and set the flags in f */
bool ParseLogCategory(uint32_t *f, const std::string *str);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer a name like SetLogCategory. Parse suggests no side-effects to me.

src/util.cpp Outdated
{LOG_COINDB, "coindb"},
{LOG_QT, "qt"},
{LOG_LEVELDB, "leveldb"},
{LOG_ALL, "1"},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add an "all" alias here, ie -debug=all is equivalent to -debug=1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup.

src/init.cpp Outdated
@@ -908,12 +905,23 @@ bool AppInitParameterInteraction()

// ********************************************************* Step 3: parameter-to-internal-flags

fDebug = mapMultiArgs.count("-debug");
bool fDebug = mapMultiArgs.count("-debug") > 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that you've removed the global fDebug bool, you can go ahead and remove it entirely and test the conditions directly (rather than make the variable local), ie:

if (mapMultiArgs.count("-debug") > 0) {

and further below:

if !(GetBoolArg("-nodebug", false) || find(categories.begin(), categories.end(), std::string("0")) != categories.end()) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point.

src/util.h Outdated
LogPrintf(__VA_ARGS__); \
} \
} while(0)
#define LogPrintf(...) LogPrintStr(tfm::format(__VA_ARGS__))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have you removed the try/except handling in this macro? (I'm not saying it's wrong, I just don't understand why it was necessary before but not now).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EDIT: I think this is a bad rebase that's reverted #9963

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Fixing.

src/tinyformat.h Outdated
@@ -167,7 +167,7 @@ namespace tinyformat {
class format_error: public std::runtime_error
{
public:
format_error(const std::string &what): std::runtime_error(what) {
format_error(const std::string &fmtwhat): std::runtime_error(fmtwhat) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad rebase?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. silencing an obnoxious shadowing warning that was making it impossible to see where other issues were.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only concern is that we occasionally pull updates to tinyformat.cpp from upstream (eg #8274), so any trivial changes like this add to the maintainer's burden when merging. Not sure if @laanwj has an opinion.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just disable the shadowing warnings please, instead of peppering unrelated variable renames in commits?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There you go: #10136

@gmaxwell
Copy link
Contributor Author

gmaxwell commented Apr 1, 2017

I think I addressed all the comments.

@laanwj
Copy link
Member

laanwj commented Apr 1, 2017

Suggestion on how to make the category more extensible without triggering big recompiles:

IMO we shouldn't worry about recompiles when the set of categories changes. That's a rare occurrence, and the way headers depend on each other almost every header change already results in a (near) full recompile.

@laanwj
Copy link
Member

laanwj commented Apr 1, 2017

utACK 21d94e7 apart from the parameter name change in tinyformat.h

This changes the logging categories to boolean flags instead of strings.

This simplifies the acceptance testing by avoiding accessing a scoped
 static thread local pointer to a thread local set of strings.  It
 eliminates the only use of boost::thread_specific_ptr outside of
 lockorder debugging.

This change allows log entries to be directed to multiple categories
 and makes it easy to change the logging flags at runtime (e.g. via
 an RPC, though that isn't done by this commit.)

It also eliminates the fDebug global.

Configuration of unknown logging categories now produces a warning.
@gmaxwell
Copy link
Contributor Author

gmaxwell commented Apr 1, 2017

(Trivally) rebased, squashed, and removed the tinyformat change.

@laanwj
Copy link
Member

laanwj commented Apr 2, 2017

Going to merge this; a change like this will need rebase after every single thing that gets merged, and @gmaxwell addressed all the nits. Further improvements can be done in later PRs.

@laanwj laanwj merged commit 6b3bb3d into bitcoin:master Apr 2, 2017
laanwj added a commit that referenced this pull request Apr 2, 2017
…s of strings.

6b3bb3d Change LogAcceptCategory to use uint32_t rather than sets of strings. (Gregory Maxwell)

Tree-SHA512: ebb5bcf9a7d00a32dd1390b727ff4d29330a038423611da01268d8e1d2c0229e52a1098e751d4e6db73ef4ae862e1e96d38249883fcaf12b68f55ebb01035b34
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request May 12, 2019
Merge bitcoin#9424: Change LogAcceptCategory to use uint32_t rather than sets of strings.

6b3bb3d Change LogAcceptCategory to use uint32_t rather than sets of strings. (Gregory Maxwell)

Tree-SHA512: ebb5bcf9a7d00a32dd1390b727ff4d29330a038423611da01268d8e1d2c0229e52a1098e751d4e6db73ef4ae862e1e96d38249883fcaf12b68f55ebb01035b34
Signed-off-by: Pasta <Pasta@dash.org>

# Conflicts:
#	src/httpserver.cpp
#	src/init.cpp
#	src/net.cpp
#	src/net_processing.cpp
#	src/policy/fees.cpp
#	src/txdb.cpp
#	src/util.cpp
#	src/util.h
#	src/validation.cpp
#	src/wallet/rpcwallet.cpp
#	src/wallet/wallet.cpp
#	src/zmq/zmqpublishnotifier.cpp
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request May 12, 2019
Merge bitcoin#9424: Change LogAcceptCategory to use uint32_t rather than sets of strings.

6b3bb3d Change LogAcceptCategory to use uint32_t rather than sets of strings. (Gregory Maxwell)

Tree-SHA512: ebb5bcf9a7d00a32dd1390b727ff4d29330a038423611da01268d8e1d2c0229e52a1098e751d4e6db73ef4ae862e1e96d38249883fcaf12b68f55ebb01035b34
Signed-off-by: Pasta <Pasta@dash.org>

31 -> 32

Signed-off-by: Pasta <Pasta@dash.org>
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request May 16, 2019
Merge bitcoin#9424: Change LogAcceptCategory to use uint32_t rather than sets of strings.

6b3bb3d Change LogAcceptCategory to use uint32_t rather than sets of strings. (Gregory Maxwell)

Tree-SHA512: ebb5bcf9a7d00a32dd1390b727ff4d29330a038423611da01268d8e1d2c0229e52a1098e751d4e6db73ef4ae862e1e96d38249883fcaf12b68f55ebb01035b34
Signed-off-by: Pasta <Pasta@dash.org>

31 -> 32

Signed-off-by: Pasta <Pasta@dash.org>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request May 17, 2019
Merge bitcoin#9424: Change LogAcceptCategory to use uint32_t rather than sets of strings.

6b3bb3d Change LogAcceptCategory to use uint32_t rather than sets of strings. (Gregory Maxwell)

Tree-SHA512: ebb5bcf9a7d00a32dd1390b727ff4d29330a038423611da01268d8e1d2c0229e52a1098e751d4e6db73ef4ae862e1e96d38249883fcaf12b68f55ebb01035b34
Signed-off-by: Pasta <Pasta@dash.org>

31 -> 32

Signed-off-by: Pasta <Pasta@dash.org>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request May 21, 2019
Merge bitcoin#9424: Change LogAcceptCategory to use uint32_t rather than sets of strings.

6b3bb3d Change LogAcceptCategory to use uint32_t rather than sets of strings. (Gregory Maxwell)

Tree-SHA512: ebb5bcf9a7d00a32dd1390b727ff4d29330a038423611da01268d8e1d2c0229e52a1098e751d4e6db73ef4ae862e1e96d38249883fcaf12b68f55ebb01035b34
Signed-off-by: Pasta <Pasta@dash.org>

31 -> 32

Signed-off-by: Pasta <Pasta@dash.org>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request May 21, 2019
Merge bitcoin#9424: Change LogAcceptCategory to use uint32_t rather than sets of strings.

6b3bb3d Change LogAcceptCategory to use uint32_t rather than sets of strings. (Gregory Maxwell)

Tree-SHA512: ebb5bcf9a7d00a32dd1390b727ff4d29330a038423611da01268d8e1d2c0229e52a1098e751d4e6db73ef4ae862e1e96d38249883fcaf12b68f55ebb01035b34
Signed-off-by: Pasta <Pasta@dash.org>

31 -> 32

Signed-off-by: Pasta <Pasta@dash.org>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request May 21, 2019
Merge bitcoin#9424: Change LogAcceptCategory to use uint32_t rather than sets of strings.

6b3bb3d Change LogAcceptCategory to use uint32_t rather than sets of strings. (Gregory Maxwell)

Tree-SHA512: ebb5bcf9a7d00a32dd1390b727ff4d29330a038423611da01268d8e1d2c0229e52a1098e751d4e6db73ef4ae862e1e96d38249883fcaf12b68f55ebb01035b34
Signed-off-by: Pasta <Pasta@dash.org>

31 -> 32

Signed-off-by: Pasta <Pasta@dash.org>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request May 22, 2019
Merge bitcoin#9424: Change LogAcceptCategory to use uint32_t rather than sets of strings.

6b3bb3d Change LogAcceptCategory to use uint32_t rather than sets of strings. (Gregory Maxwell)

Tree-SHA512: ebb5bcf9a7d00a32dd1390b727ff4d29330a038423611da01268d8e1d2c0229e52a1098e751d4e6db73ef4ae862e1e96d38249883fcaf12b68f55ebb01035b34
Signed-off-by: Pasta <Pasta@dash.org>

31 -> 32

Signed-off-by: Pasta <Pasta@dash.org>
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request May 22, 2019
Merge bitcoin#9424: Change LogAcceptCategory to use uint32_t rather than sets of strings.

6b3bb3d Change LogAcceptCategory to use uint32_t rather than sets of strings. (Gregory Maxwell)

Tree-SHA512: ebb5bcf9a7d00a32dd1390b727ff4d29330a038423611da01268d8e1d2c0229e52a1098e751d4e6db73ef4ae862e1e96d38249883fcaf12b68f55ebb01035b34
Signed-off-by: Pasta <Pasta@dash.org>

31 -> 32

Signed-off-by: Pasta <Pasta@dash.org>
UdjinM6 pushed a commit to dashpay/dash that referenced this pull request May 22, 2019
* Contains dashification. disables `-debug dash`
Merge bitcoin#9424: Change LogAcceptCategory to use uint32_t rather than sets of strings.

6b3bb3d Change LogAcceptCategory to use uint32_t rather than sets of strings. (Gregory Maxwell)

Tree-SHA512: ebb5bcf9a7d00a32dd1390b727ff4d29330a038423611da01268d8e1d2c0229e52a1098e751d4e6db73ef4ae862e1e96d38249883fcaf12b68f55ebb01035b34
Signed-off-by: Pasta <Pasta@dash.org>

31 -> 32

Signed-off-by: Pasta <Pasta@dash.org>

* Merge bitcoin#10123: Allow debug logs to be excluded from specified component

3bde556 Add -debugexclude option to switch off logging for specified components (John Newbery)

Tree-SHA512: 30202e3f2085fc2fc5dd4bedb92988f4cb162c612a42cf8f6395a7da326f34975ddc347f82bc4ddca6c84c438dc0cc6e87869f90c7ff88105dbeaa52a947fa43

* bump to uint64_t due to added Dash codes

Signed-off-by: Pasta <Pasta@dash.org>

* bump to uint64_t due to added Dash codes cont.

Signed-off-by: Pasta <Pasta@dash.org>

* string -> BCLog format

Signed-off-by: Pasta <Pasta@dash.org>

* uint32_t -> uint64_t

Signed-off-by: Pasta <Pasta@dash.org>

* Fix CBatchedLogger

* Fix most fDebug-s

* Fix `debug` rpc

* Fix BENCH and RAND conflicts

* Add ALERT and use it

* Update LogPrint-s in dash-specific code

* Tweak few log categories

Specifically:
- use PRIVATESEND in `CPrivateSendClientManager::GetRandomNotUsedMasternode()`
- use ZMQ in `CZMQPublishRawGovernanceVoteNotifier::NotifyGovernanceVote()` and `CZMQPublishRawGovernanceObjectNotifier::NotifyGovernanceObject()`

* Drop no longer used MASTERNODE category

* Merge bitcoin#10153: logging: Fix off-by-one for shrinkdebugfile default

faab624 logging: Fix off-by-one for shrinkdebugfile (MarcoFalke)

Tree-SHA512: d6153e06067906172ff0611af9e585a3ecf0a7d56925b6ad7c12e75aa802441047059b9b6f6c78e79916c3f2abc8f1998bfd2d5b84201ec6421f727c08da3c21

* Shift dash-specific log categories to start from `1ul << 32` to avoid potential future conflicts with bitcoin ones

* Fix `dash` category

* remove debugCategories

Signed-off-by: Pasta <Pasta@dash.org>

* Prepend "std::" to find call

* Check for BCLog::PRIVATESEND instead of logCategories != BCLog::NONE

* Use BCLog::MNPAYMENTS category instead of checking for logCategories != BCLog::NONE

* Move "End Dash" comment below "ALERT"

When adding new entries here, we'll otherwise get confused with ordering
and might end up forgetting that adding something Dash specific must
continue with the bit after 43.
barrystyle pushed a commit to PACGlobalOfficial/PAC that referenced this pull request Jan 22, 2020
* Contains dashification. disables `-debug dash`
Merge bitcoin#9424: Change LogAcceptCategory to use uint32_t rather than sets of strings.

6b3bb3d Change LogAcceptCategory to use uint32_t rather than sets of strings. (Gregory Maxwell)

Tree-SHA512: ebb5bcf9a7d00a32dd1390b727ff4d29330a038423611da01268d8e1d2c0229e52a1098e751d4e6db73ef4ae862e1e96d38249883fcaf12b68f55ebb01035b34
Signed-off-by: Pasta <Pasta@dash.org>

31 -> 32

Signed-off-by: Pasta <Pasta@dash.org>

* Merge bitcoin#10123: Allow debug logs to be excluded from specified component

3bde556 Add -debugexclude option to switch off logging for specified components (John Newbery)

Tree-SHA512: 30202e3f2085fc2fc5dd4bedb92988f4cb162c612a42cf8f6395a7da326f34975ddc347f82bc4ddca6c84c438dc0cc6e87869f90c7ff88105dbeaa52a947fa43

* bump to uint64_t due to added Dash codes

Signed-off-by: Pasta <Pasta@dash.org>

* bump to uint64_t due to added Dash codes cont.

Signed-off-by: Pasta <Pasta@dash.org>

* string -> BCLog format

Signed-off-by: Pasta <Pasta@dash.org>

* uint32_t -> uint64_t

Signed-off-by: Pasta <Pasta@dash.org>

* Fix CBatchedLogger

* Fix most fDebug-s

* Fix `debug` rpc

* Fix BENCH and RAND conflicts

* Add ALERT and use it

* Update LogPrint-s in dash-specific code

* Tweak few log categories

Specifically:
- use PRIVATESEND in `CPrivateSendClientManager::GetRandomNotUsedMasternode()`
- use ZMQ in `CZMQPublishRawGovernanceVoteNotifier::NotifyGovernanceVote()` and `CZMQPublishRawGovernanceObjectNotifier::NotifyGovernanceObject()`

* Drop no longer used MASTERNODE category

* Merge bitcoin#10153: logging: Fix off-by-one for shrinkdebugfile default

faab624 logging: Fix off-by-one for shrinkdebugfile (MarcoFalke)

Tree-SHA512: d6153e06067906172ff0611af9e585a3ecf0a7d56925b6ad7c12e75aa802441047059b9b6f6c78e79916c3f2abc8f1998bfd2d5b84201ec6421f727c08da3c21

* Shift dash-specific log categories to start from `1ul << 32` to avoid potential future conflicts with bitcoin ones

* Fix `dash` category

* remove debugCategories

Signed-off-by: Pasta <Pasta@dash.org>

* Prepend "std::" to find call

* Check for BCLog::PRIVATESEND instead of logCategories != BCLog::NONE

* Use BCLog::MNPAYMENTS category instead of checking for logCategories != BCLog::NONE

* Move "End Dash" comment below "ALERT"

When adding new entries here, we'll otherwise get confused with ordering
and might end up forgetting that adding something Dash specific must
continue with the bit after 43.
furszy added a commit to PIVX-Project/PIVX that referenced this pull request Apr 1, 2020
…of strings

c3dc816 [Core] LogAcceptCategory: use uint32_t rather than sets of strings (random-zebra)

Pull request description:

  implemented on top of:
  - [x] #1449

  from bitcoin#9424

  > This changes the logging categories to boolean flags instead of strings.
  This simplifies the acceptance testing by avoiding accessing a scoped static thread local pointer to a thread local set of strings. It eliminates the only use of boost::thread_specific_ptr outside of lockorder debugging.
  This change allows log entries to be directed to multiple categories and makes it easy to change the logging flags at runtime (e.g. via an RPC, though that isn't done by this commit.)
  It also eliminates the fDebug global.
  Configuration of unknown logging categories now produces a warning.

  We add 4 more debug categories:
  - BCLog::STAKING
  - BCLog::MASTERNODE (which includes previous "masternode" and "mnpayments" categories)
  - BCLog::MNBUDGET
  - BCLog::LEGACYZC

ACKs for top commit:
  Fuzzbawls:
    ACK c3dc816

Tree-SHA512: 0c2ffc30df5b4239396c6f2ef6c551bbca5696aa1087b5e12a206fc9b1def9ef6cd9c6f6c0cbbb8da0d667e782848a884514de21609714668d0b5ad87eca8e56
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet