-
-
Notifications
You must be signed in to change notification settings - Fork 273
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
chore(suite-desktop): enable trezor-connect logger when debug mode is… #16699
Conversation
I will check it , app builds here https://github.com/trezor/trezor-suite/actions/runs/13073791768 |
QA OK Info:
with debug
|
Any chance we can add it as startup flag ? |
WalkthroughThe changes modify the initialization of TrezorConnect within the IPC proxy options. Specifically, the update involves introducing the Suggested reviewers
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
724bd42 |
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/suite-desktop-core/src/modules/trezor-connect.ts
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
- GitHub Check: run-desktop-tests (@group=wallet, trezor-user-env-unix bitcoin-regtest)
- GitHub Check: run-desktop-tests (@group=settings, trezor-user-env-unix bitcoin-regtest)
- GitHub Check: run-desktop-tests (@group=device-management, trezor-user-env-unix)
- GitHub Check: Analyze with CodeQL (javascript)
- GitHub Check: Setup and Cache Dependencies
- GitHub Check: build-web
- GitHub Check: run-desktop-tests (@group=suite, trezor-user-env-unix)
🔇 Additional comments (1)
packages/suite-desktop-core/src/modules/trezor-connect.ts (1)
1-1
: LGTM!The addition of the
app
import from 'electron' is necessary for accessing command line arguments.
const response = await TrezorConnect.init({ | ||
...params[0], | ||
// poor mans solution to enable debug logs in trezor-connect. | ||
// todo: ideally connect should accept logger as a param | ||
debug: app?.commandLine.getSwitchValue('log-connect') === 'true', | ||
}); |
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.
💡 Codebase verification
Attention: Debug Flag Inconsistency in TrezorConnect.init Needs Resolution
After reviewing the logging switches in the codebase, we've confirmed the following:
-
Inconsistent Flag Usage:
- In
packages/suite-desktop-core/src/libs/logger.ts
, the log level is retrieved using thelog-level
flag. - In
packages/suite-desktop-core/src/modules/trezor-connect.ts
, the code uses a separatelog-connect
flag. This introduces inconsistency and potential confusion.
- In
-
Strict String Comparison:
The current check (app?.commandLine.getSwitchValue('log-connect') === 'true'
) is very rigid. It might be beneficial to consider a more flexible check for truthy values. -
Documentation Gap:
There is no documentation explaining how to use thelog-connect
flag, which could lead to misunderstandings. -
Temporary Solution Acknowledgment:
The included TODO comment indicates that passing a logger as a parameter would be a better, long-term solution.
Given these points, it is advisable to align the logging flag with the rest of the codebase (e.g., using --log-level=connect
if that meets your requirements) or to add clear documentation if a distinct flag is intentionally used for TrezorConnect debugging.
🔗 Analysis chain
Consider improving the command line switch implementation.
While the implementation works, there are a few suggestions for improvement:
- Consider aligning with existing logging flags by using
--log-level=connect
instead oflog-connect=true
for consistency with the existing--log-level=debug
flag. - The string comparison with 'true' could be more flexible to accept various truthy values.
- Add documentation on how to use this new flag.
Consider this alternative implementation:
- debug: app?.commandLine.getSwitchValue('log-connect') === 'true',
+ debug: app?.commandLine.getSwitchValue('log-level') === 'connect',
The TODO comment suggests passing a logger as a parameter would be a better solution. This would indeed be more flexible and maintainable in the long term. Consider creating a follow-up ticket to track this improvement.
Let's verify if there are any other logging-related command line switches in use:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Search for command line argument handling related to logging
# Test: Look for patterns related to log level or debug flags
rg -A 3 'commandLine.+(log|debug)'
Length of output: 2053
/rebase |
Start rebasing: https://github.com/trezor/trezor-suite/actions/runs/13112913180 |
724bd42
to
c5ea2cc
Compare
QA OK
|
sometimes it might be useful to see logs from a production build running, mainly in case when we can reproduce an issue on a specific computer. We opened this topic together with @MiroslavProchazka while we were debugging some firmware update issues.
This PR brings a very naive way to achieve this - when debug mode is active during the startup of the suite-desktop app you get connect logs printed to stdout.