-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Remove duplicated "Error: " prefix in logs #15894
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
Remove duplicated "Error: " prefix in logs #15894
Conversation
ryanofsky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK ad2b70aa26cecbcc42c305401855212de9b3c26c. Code change seems good, but I think ideally the line would appear as "Error: Disk space is low!" in both the GUI and in the log. As it stands currently, it seems this like this change makes the log message better but the GUI message a little worse.
|
utACK ad2b70aa26cecbcc42c305401855212de9b3c26c |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
utACK ad2b70a, that was annoying me too. @ryanofsky I don't think the UI dialog text needs a "Error: " prefix. The dialog title and giant red icon make it clear enough that this is an error. |
|
@promag https://doc.qt.io/qt-5/qmessagebox.html#setWindowTitle
I can see two possible ways:
Which one is more preferable? |
|
I agree with @ryanofsky, having equal messages isn't that terrible, especially when it's about to quit. |
|
Thanks for working on this. Maybe the wording should be more "final" since "low" is eventually something that is non-critical were "too low" would be understandable (together with red error sign). |
|
Maybe add a comment in source to remind us of the macOS situation. |
|
What about prepending the prefix based on the error type? diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index abf9136eee..851bfe2b71 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -1022,9 +1022,9 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
progressBar->setToolTip(tooltip);
}
-void BitcoinGUI::message(const QString &title, const QString &message, unsigned int style, bool *ret)
+void BitcoinGUI::message(const QString& title, QString message, unsigned int style, bool* ret)
{
- QString strTitle = tr("Bitcoin"); // default title
+ QString strTitle{PACKAGE_NAME}; // default title
// Default to information icon
int nMBoxIcon = QMessageBox::Information;
int nNotifyIcon = Notificator::Information;
@@ -1039,20 +1039,24 @@ void BitcoinGUI::message(const QString &title, const QString &message, unsigned
switch (style) {
case CClientUIInterface::MSG_ERROR:
msgType = tr("Error");
+ message = tr("Error") + ": " + message;
break;
case CClientUIInterface::MSG_WARNING:
msgType = tr("Warning");
+ message = tr("Warning") + ": " + message;
break;
case CClientUIInterface::MSG_INFORMATION:
msgType = tr("Information");
+ message = tr("Information") + ": " + message;
break;
default:
break;
}
}
- // Append title to "Bitcoin - "
- if (!msgType.isEmpty())
+ // Append type to title
+ if (!msgType.isEmpty()) {
strTitle += " - " + msgType;
+ }
// Check for error/warning icon
if (style & CClientUIInterface::ICON_ERROR) {
diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h
index b58ccbb455..54a4b3903c 100644
--- a/src/qt/bitcoingui.h
+++ b/src/qt/bitcoingui.h
@@ -219,7 +219,7 @@ public Q_SLOTS:
@see CClientUIInterface::MessageBoxFlags
@param[in] ret pointer to a bool that will be modified to whether Ok was clicked (modal only)
*/
- void message(const QString &title, const QString &message, unsigned int style, bool *ret = nullptr);
+ void message(const QString& title, QString message, unsigned int style, bool* ret = nullptr);
#ifdef ENABLE_WALLET
void setCurrentWallet(WalletModel* wallet_model); |
|
re: #15894 (comment)
Formatting could be part of the translation: message = tr("Error: %s", message) |
|
Currently, Bitcoin Core code has the following features. The
The
Unfortunately, I cannot see the simple way to refactor the code to achieve both uniformity and usability. Any thoughts? |
|
re: #15894 (comment) from hebasto
I think it'd make sense to just focus on implementing desired behavior this PR, and not do a broad refactoring at the same time. It sounds like the goal is just to get identical translated "Error: Disk space is low!" messages to show up in the log and dialogs. Refactoring is something that can come later, and usually refactoring changes are more reviewable if they don't change behavior. I think the easiest way to keep the PR limited would be to define a new As for a bigger refactoring, I think Marco's suggested change #15894 (comment) could be a good idea since it makes An alternative would go the opposite direction and make std::string FormatError(const std::string& message)
{
return strprintf(_("Error: %s"), message);
}
std::string FormatWarning(const std::string& message)
{
return strprintf(_("Warning: %s"), message);
} |
|
Logging translated messages to debug.log is a bug (it makes the log useless as universally understood debugging medium) Steps to reproduce: |
|
@MarcoFalke |
Does this impact my suggestion above? It seems like currently we log both translated and untranslated messages, and after my suggestion we'd continue to do that. My suggestion is just about making prefixes in translated messages consistent. More generally, I don't see any harm in logging translated messages next to untranslated messages. Seems fine if you want to drop translated messages, though. |
|
Just a reminder:
|
ad2b70a to
657db09
Compare
|
The following comments have been addressed:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 657db0932e3a9621935c5edc36ae269c80d6d9a4. To be sure, this is not the change I was suggesting. I would have preferred to just add the "Error:" prefix unconditionally in AbortNode() so it wouldn't need to have a new argument added. I also would have preferred not to change BitcoinGUI::message so the scope of this PR would be limited to AbortNode calls and not affect every other error dialog. But either way this is ok.
657db09 to
4dc36fa
Compare
ryanofsky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 4dc36faf4b9b419ae1eec837e36d0bb60a6255b3. Only change since last review is capitalization.
It forces do not prepend error/warning prefix.
4dc36fa to
f724f31
Compare
|
Rebased. |
|
concept and code-review ACK f724f31 |
f724f31 Make AbortNode() aware of MSG_NOPREFIX flag (Hennadii Stepanov) 96fd4ee Add MSG_NOPREFIX flag for user messages (Hennadii Stepanov) f0641f2 Prepend the error/warning prefix for GUI messages (Hennadii Stepanov) Pull request description: The "Error" prefix/title is set already in the next functions: - `noui_ThreadSafeMessageBox()`https://github.com/bitcoin/bitcoin/blob/2068f089c8b7b90eb4557d3f67ea0f0ed2059a23/src/noui.cpp#L17 - `ThreadSafeMessageBox()`https://github.com/bitcoin/bitcoin/blob/a720a983015c9ef8cc814c16a5b9ef6379695817/src/qt/bitcoingui.cpp#L1351 Currently on master:  With this PR:  ACKs for top commit: laanwj: concept and code-review ACK f724f31 Tree-SHA512: 218a179b81cc2ac64239d833c02b4c4d4da9b976728a2dcd645966726c4c660b6f1fe43aa28f33d1cb566785a4329e7f93bf5a502bf202316db79d2ff5fce0f8
maflcko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some questions
|
@MarcoFalke Thank you for your review. I could see my code from another point of view. |
18bd83b util: Cleanup translation.h (Hennadii Stepanov) e95e658 doc: Do not translate technical or extremely rare errors (Hennadii Stepanov) 7e923d4 Make InitError bilingual (Hennadii Stepanov) 917ca93 Make ThreadSafe{MessageBox|Question} bilingual (Hennadii Stepanov) 23b9fa2 gui: Add detailed text to BitcoinGUI::message (Hennadii Stepanov) Pull request description: This is an alternative to #15340 (it works with the `Chain` interface; see: #15340 (comment)). Refs: - #16218 (partial fix) - #15894 (comment) This PR: - makes GUI error messages bilingual: user's native language + untranslated (i.e. English) - insures that only untranslated messages are written to the debug log file and to `stderr` (that is not the case on master). If a translated string is unavailable only an English string appears to a user. Here are some **examples** (updated):   * `qt5ct: using qt5ct plugin` message is my local environment specific; please ignore it. --- Note for reviewers: `InitWarning()` is out of this PR scope. ACKs for top commit: Sjors: re-tACK 18bd83b MarcoFalke: ACK 18bd83b 🐦 Tree-SHA512: 3cc8ec44f84403e54b57d11714c86b0855ed90eb794b5472e432005073354b9e3f7b4e8e7bf347a4c21be47299dbc7170f2d0c4b80e308205ff09596e55a4f96
18bd83b util: Cleanup translation.h (Hennadii Stepanov) e95e658 doc: Do not translate technical or extremely rare errors (Hennadii Stepanov) 7e923d4 Make InitError bilingual (Hennadii Stepanov) 917ca93 Make ThreadSafe{MessageBox|Question} bilingual (Hennadii Stepanov) 23b9fa2 gui: Add detailed text to BitcoinGUI::message (Hennadii Stepanov) Pull request description: This is an alternative to bitcoin#15340 (it works with the `Chain` interface; see: bitcoin#15340 (comment)). Refs: - bitcoin#16218 (partial fix) - bitcoin#15894 (comment) This PR: - makes GUI error messages bilingual: user's native language + untranslated (i.e. English) - insures that only untranslated messages are written to the debug log file and to `stderr` (that is not the case on master). If a translated string is unavailable only an English string appears to a user. Here are some **examples** (updated):   * `qt5ct: using qt5ct plugin` message is my local environment specific; please ignore it. --- Note for reviewers: `InitWarning()` is out of this PR scope. ACKs for top commit: Sjors: re-tACK 18bd83b MarcoFalke: ACK 18bd83b 🐦 Tree-SHA512: 3cc8ec44f84403e54b57d11714c86b0855ed90eb794b5472e432005073354b9e3f7b4e8e7bf347a4c21be47299dbc7170f2d0c4b80e308205ff09596e55a4f96
Summary: bitcoin/bitcoin@f0641f2 --- Partial backport of Core [[bitcoin/bitcoin#15894 | PR15894]] Test Plan: ninja check Reviewers: #bitcoin_abc, jasonbcox Reviewed By: #bitcoin_abc, jasonbcox Differential Revision: https://reviews.bitcoinabc.org/D7124
Summary: It forces do not prepend error/warning prefix. bitcoin/bitcoin@96fd4ee --- Depends on D7124 Partial backport of Core [[bitcoin/bitcoin#15894 | PR15894]] Test Plan: ninja check Reviewers: #bitcoin_abc, jasonbcox Reviewed By: #bitcoin_abc, jasonbcox Differential Revision: https://reviews.bitcoinabc.org/D7125
Summary: bitcoin/bitcoin@f724f31 --- Depends on D7125 Concludes backport of Core [[bitcoin/bitcoin#15894 | PR15894]] Test Plan: ninja check check-functional Reviewers: #bitcoin_abc, jasonbcox Reviewed By: #bitcoin_abc, jasonbcox Differential Revision: https://reviews.bitcoinabc.org/D7126
f724f31 Make AbortNode() aware of MSG_NOPREFIX flag (Hennadii Stepanov) 96fd4ee Add MSG_NOPREFIX flag for user messages (Hennadii Stepanov) f0641f2 Prepend the error/warning prefix for GUI messages (Hennadii Stepanov) Pull request description: The "Error" prefix/title is set already in the next functions: - `noui_ThreadSafeMessageBox()`https://github.com/bitcoin/bitcoin/blob/2068f089c8b7b90eb4557d3f67ea0f0ed2059a23/src/noui.cpp#L17 - `ThreadSafeMessageBox()`https://github.com/bitcoin/bitcoin/blob/a720a983015c9ef8cc814c16a5b9ef6379695817/src/qt/bitcoingui.cpp#L1351 Currently on master:  With this PR:  ACKs for top commit: laanwj: concept and code-review ACK f724f31 Tree-SHA512: 218a179b81cc2ac64239d833c02b4c4d4da9b976728a2dcd645966726c4c660b6f1fe43aa28f33d1cb566785a4329e7f93bf5a502bf202316db79d2ff5fce0f8


The "Error" prefix/title is set already in the next functions:
noui_ThreadSafeMessageBox()bitcoin/src/noui.cpp
Line 17 in 2068f08
ThreadSafeMessageBox()bitcoin/src/qt/bitcoingui.cpp
Line 1351 in a720a98
Currently on master:

With this PR:
