RPC: Improve help text and behavior of RPC-logging.#11191
RPC: Improve help text and behavior of RPC-logging.#11191laanwj merged 1 commit intobitcoin:masterfrom
Conversation
73494d1 to
0a9c8c7
Compare
src/rpc/misc.cpp
Outdated
| uint32_t flag = 0; | ||
| std::string cat = cats[i].get_str(); | ||
| if (!GetLogCategory(&flag, &cat)) { | ||
| if (!GetLogCategory(&flag, &cat) || (cat == "0" || cat == "1")) { |
There was a problem hiding this comment.
According to the help text, this is a valid "category":
-debug=<category>
Output debugging information (default: 0, ...
There was a problem hiding this comment.
@MarcoFalke Thank you for your review.
Oh, indeed.
I think -debug=1(or0) is very clear for initial parameter, but I'm afraid that it is a little bit hard to understand that "0" is ignored in this RPC command.
So, I will add {BCLog::NONE, "none"} to LogCategories[] and add to the help text that "0" and "1" are the shorthand of "none" and "all".
There was a problem hiding this comment.
I wasn't even aware of this rpc. You might want to wait for feedback by someone who used this. Though, I think your suggestion makes sense.
There was a problem hiding this comment.
Then, I will wait for feedback for a while, thanks.
|
Concept ACK |
|
@MarcoFalke I added the followings:
|
| throw JSONRPCError(RPC_INVALID_PARAMETER, "unknown logging category " + cat); | ||
| } | ||
| if (flag == BCLog::NONE) | ||
| return 0; |
There was a problem hiding this comment.
Style: Either use same line (if (..) return 0;) or use braces (
if (..) {
return 0;
}
src/rpc/misc.cpp
Outdated
| if (request.fHelp || request.params.size() > 2) { | ||
| throw std::runtime_error( | ||
| "logging [include,...] <exclude>\n" | ||
| "logging (<include> <exclude>)\n" |
There was a problem hiding this comment.
The standard is to have put space after ( and before ) for optional args, i.e. ( <include> <exclude> )
src/rpc/misc.cpp
Outdated
| "When called without an argument, returns the list of categories that are currently being debug logged.\n" | ||
| "When called with arguments, adds or removes categories from debug logging.\n" | ||
| "When called without an argument, returns the list of categories with status that are currently being debug logged or not.\n" | ||
| "When called with arguments, adds or removes categories from debug logging and return the list above.\n" |
There was a problem hiding this comment.
and returns the list (s)
src/rpc/misc.cpp
Outdated
| "When called with arguments, adds or removes categories from debug logging.\n" | ||
| "When called without an argument, returns the list of categories with status that are currently being debug logged or not.\n" | ||
| "When called with arguments, adds or removes categories from debug logging and return the list above.\n" | ||
| "The argument are evaluated for \"include\" first. That is, \"exclude\" takes precedence.\n" |
There was a problem hiding this comment.
A bit hard to understand. Maybe: The arguments are evaluated in order \"include\", \"exclude\". If an item is both included and excluded, it will thus end up being excluded.
src/rpc/misc.cpp
Outdated
| "1. \"include\" (array of strings) add debug logging for these categories.\n" | ||
| "2. \"exclude\" (array of strings) remove debug logging for these categories.\n" | ||
| "\nResult: <categories> (string): a list of the logging categories that are active.\n" | ||
| "In addition, the following are available as a category name with special meanings:\n" |
18ceaaa to
bff0625
Compare
|
@kallewoof Thank you for your review. |
|
Please squash 1830d5c |
src/init.cpp
Outdated
There was a problem hiding this comment.
[](const auto& cat){return cat == "0" || cat == "none";}There was a problem hiding this comment.
@promag thank you for your review.
- auto specifier can not use in lambda epression when -std=c++11.
- std::string has == operater with c-string.
so I will change to following:
[](std::string cat){return cat == "0" || cat == "none";})) {
There was a problem hiding this comment.
BTW, this is not the 1st time I would prefer to read:
std::set<std::string> categories = gArgs.GetUniqueArgs("-debug");
if (!categories.count("0") && !categories.count("none")) {Or simply:
if (!gArgs.IsArgSet("-debug", "0") && !gArgs.IsArgSet("-debug", "none")) {A) The changes in behavior are as follows: 1. Introduce logging category "none" as alias of "0" for both RPC-logging and bitcoind "-debug" parameter. 2. Same as "0" is given to argument of "-debug", if "none" or "0" is given to <include>, all other given logging categories are ignored. The same is true for <exclude>. (Before this PR, "0" was accepted but just be ignored itself.) B) The changes in the help text are as follows: 1. Add a descrption about the evaluation order of <include> and <exclude> to clarify how debug loggig categories to be set. 2. Delete text that describe restriction about libevent because it's already allowed libevent logging to be updated during runtime. 3. Add a description for category "all", "1", "none" and "0". 4. Add "optional" to the help text of <include> and <exclude>. 5. Add missing new lines before "Argument:". 6. This RPC always returns all logging categories with status. Fix the help text to match this behavior.
97a9531 to
c60c49b
Compare
|
Lightly tested ACK c60c49b |
c60c49b Improve help text and behavior of RPC-logging (Akio Nakamura) Pull request description: 1. It is allowed `libevent` logging to be updated during runtime, but still described that restriction in the help text. So we delete these text. 2. Add a descrption about the evaluation order of `<include>` and `<exclude>` to clarify how debug loggig categories to be set. 3. Add a description about the available logging category `"all"` which is not explained. 4. Add `"optional"` to the help text of `<include>` and `<exclude>`. 5. Add missing new lines before `"Argument:"`. 6. `"0"`,`"1"` are allowed in both array of `<include>` and `<exclude>`. `"0"` is **ignored** and `"1"` is treated **same as** `"all"`. It is confusing, so forbid them. 7. It always returns all logging categories with status. Fix the help text to match this behavior. Tree-SHA512: c2142da1a9bf714af8ebc38ac0d82394e2073fc0bd56f136372e3db7b2af3b6746f8d6b0241fe66c1698c208c124deb076be83f07dec0d0a180ad150593af415
Summary: c60c49b Improve help text and behavior of RPC-logging (Akio Nakamura) Pull request description: 1. It is allowed `libevent` logging to be updated during runtime, but still described that restriction in the help text. So we delete these text. 2. Add a descrption about the evaluation order of `<include>` and `<exclude>` to clarify how debug loggig categories to be set. 3. Add a description about the available logging category `"all"` which is not explained. 4. Add `"optional"` to the help text of `<include>` and `<exclude>`. 5. Add missing new lines before `"Argument:"`. 6. `"0"`,`"1"` are allowed in both array of `<include>` and `<exclude>`. `"0"` is **ignored** and `"1"` is treated **same as** `"all"`. It is confusing, so forbid them. 7. It always returns all logging categories with status. Fix the help text to match this behavior. Tree-SHA512: c2142da1a9bf714af8ebc38ac0d82394e2073fc0bd56f136372e3db7b2af3b6746f8d6b0241fe66c1698c208c124deb076be83f07dec0d0a180ad150593af415 Backport Core PR11191 bitcoin/bitcoin#11191 Depends on D3684 Test Plan: make check ./bitcoind ./bitcoin-cli help logging Changes should be reflected in the help text Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc Reviewed By: Fabien, O1 Bitcoin ABC, #bitcoin_abc Differential Revision: https://reviews.bitcoinabc.org/D3699
c60c49b Improve help text and behavior of RPC-logging (Akio Nakamura) Pull request description: 1. It is allowed `libevent` logging to be updated during runtime, but still described that restriction in the help text. So we delete these text. 2. Add a descrption about the evaluation order of `<include>` and `<exclude>` to clarify how debug loggig categories to be set. 3. Add a description about the available logging category `"all"` which is not explained. 4. Add `"optional"` to the help text of `<include>` and `<exclude>`. 5. Add missing new lines before `"Argument:"`. 6. `"0"`,`"1"` are allowed in both array of `<include>` and `<exclude>`. `"0"` is **ignored** and `"1"` is treated **same as** `"all"`. It is confusing, so forbid them. 7. It always returns all logging categories with status. Fix the help text to match this behavior. Tree-SHA512: c2142da1a9bf714af8ebc38ac0d82394e2073fc0bd56f136372e3db7b2af3b6746f8d6b0241fe66c1698c208c124deb076be83f07dec0d0a180ad150593af415
Summary:
c60c49b Improve help text and behavior of RPC-logging (Akio Nakamura)
Pull request description:
1. It is allowed `libevent` logging to be updated during runtime,
but still described that restriction in the help text.
So we delete these text.
2. Add a descrption about the evaluation order of `<include>` and
`<exclude>` to clarify how debug loggig categories to be set.
3. Add a description about the available logging category `"all"`
which is not explained.
4. Add `"optional"` to the help text of `<include>` and `<exclude>`.
5. Add missing new lines before `"Argument:"`.
6. `"0"`,`"1"` are allowed in both array of `<include>` and `<exclude>`.
`"0"` is **ignored** and `"1"` is treated **same as** `"all"`.
It is confusing, so forbid them.
7. It always returns all logging categories with status.
Fix the help text to match this behavior.
Tree-SHA512: c2142da1a9bf714af8ebc38ac0d82394e2073fc0bd56f136372e3db7b2af3b6746f8d6b0241fe66c1698c208c124deb076be83f07dec0d0a180ad150593af415
Backport Core PR11191
bitcoin/bitcoin#11191
Depends on D3684
Test Plan:
make check
./bitcoind
./bitcoin-cli help logging
Changes should be reflected in the help text
Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc
Reviewed By: Fabien, O1 Bitcoin ABC, #bitcoin_abc
Differential Revision: https://reviews.bitcoinabc.org/D3699
Summary:
c60c49b Improve help text and behavior of RPC-logging (Akio Nakamura)
Pull request description:
1. It is allowed `libevent` logging to be updated during runtime,
but still described that restriction in the help text.
So we delete these text.
2. Add a descrption about the evaluation order of `<include>` and
`<exclude>` to clarify how debug loggig categories to be set.
3. Add a description about the available logging category `"all"`
which is not explained.
4. Add `"optional"` to the help text of `<include>` and `<exclude>`.
5. Add missing new lines before `"Argument:"`.
6. `"0"`,`"1"` are allowed in both array of `<include>` and `<exclude>`.
`"0"` is **ignored** and `"1"` is treated **same as** `"all"`.
It is confusing, so forbid them.
7. It always returns all logging categories with status.
Fix the help text to match this behavior.
Tree-SHA512: c2142da1a9bf714af8ebc38ac0d82394e2073fc0bd56f136372e3db7b2af3b6746f8d6b0241fe66c1698c208c124deb076be83f07dec0d0a180ad150593af415
Backport Core PR11191
bitcoin/bitcoin#11191
Depends on D3684
Test Plan:
make check
./bitcoind
./bitcoin-cli help logging
Changes should be reflected in the help text
Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc
Reviewed By: Fabien, O1 Bitcoin ABC, #bitcoin_abc
Differential Revision: https://reviews.bitcoinabc.org/D3699
Summary:
c60c49b Improve help text and behavior of RPC-logging (Akio Nakamura)
Pull request description:
1. It is allowed `libevent` logging to be updated during runtime,
but still described that restriction in the help text.
So we delete these text.
2. Add a descrption about the evaluation order of `<include>` and
`<exclude>` to clarify how debug loggig categories to be set.
3. Add a description about the available logging category `"all"`
which is not explained.
4. Add `"optional"` to the help text of `<include>` and `<exclude>`.
5. Add missing new lines before `"Argument:"`.
6. `"0"`,`"1"` are allowed in both array of `<include>` and `<exclude>`.
`"0"` is **ignored** and `"1"` is treated **same as** `"all"`.
It is confusing, so forbid them.
7. It always returns all logging categories with status.
Fix the help text to match this behavior.
Tree-SHA512: c2142da1a9bf714af8ebc38ac0d82394e2073fc0bd56f136372e3db7b2af3b6746f8d6b0241fe66c1698c208c124deb076be83f07dec0d0a180ad150593af415
Backport Core PR11191
bitcoin/bitcoin#11191
Depends on D3684
Test Plan:
make check
./bitcoind
./bitcoin-cli help logging
Changes should be reflected in the help text
Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc
Reviewed By: Fabien, O1 Bitcoin ABC, #bitcoin_abc
Differential Revision: https://reviews.bitcoinabc.org/D3699
c60c49b Improve help text and behavior of RPC-logging (Akio Nakamura) Pull request description: 1. It is allowed `libevent` logging to be updated during runtime, but still described that restriction in the help text. So we delete these text. 2. Add a descrption about the evaluation order of `<include>` and `<exclude>` to clarify how debug loggig categories to be set. 3. Add a description about the available logging category `"all"` which is not explained. 4. Add `"optional"` to the help text of `<include>` and `<exclude>`. 5. Add missing new lines before `"Argument:"`. 6. `"0"`,`"1"` are allowed in both array of `<include>` and `<exclude>`. `"0"` is **ignored** and `"1"` is treated **same as** `"all"`. It is confusing, so forbid them. 7. It always returns all logging categories with status. Fix the help text to match this behavior. Tree-SHA512: c2142da1a9bf714af8ebc38ac0d82394e2073fc0bd56f136372e3db7b2af3b6746f8d6b0241fe66c1698c208c124deb076be83f07dec0d0a180ad150593af415
libeventlogging to be updated during runtime,but still described that restriction in the help text.
So we delete these text.
<include>and<exclude>to clarify how debug loggig categories to be set."all"which is not explained.
"optional"to the help text of<include>and<exclude>."Argument:"."0","1"are allowed in both array of<include>and<exclude>."0"is ignored and"1"is treated same as"all".It is confusing, so forbid them.
Fix the help text to match this behavior.