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

chore(suite-desktop): enable trezor-connect logger when debug mode is… #16699

Merged
merged 1 commit into from
Feb 3, 2025

Conversation

mroz22
Copy link
Contributor

@mroz22 mroz22 commented Jan 29, 2025

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.

@mroz22 mroz22 added the no-project This label is used to specify that PR doesn't need to be added to a project label Jan 29, 2025
@bosomt
Copy link
Contributor

bosomt commented Jan 31, 2025

I will check it , app builds here https://github.com/trezor/trezor-suite/actions/runs/13073791768

@bosomt
Copy link
Contributor

bosomt commented Jan 31, 2025

QA OK

Info:

  • Suite version: desktop 25.2.0 (8d27bcd)
  • Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) TrezorSuiteDev/25.2.0 Chrome/128.0.6613.186 Electron/32.2.6 Safari/537.36
  • OS: MacIntel
  • Screen: 1470x956
  • Device:
  • Transport: BridgeTransport 2.0.33
    no debug
Last login: Fri Jan 31 14:47:07 on ttys000
bosomt@Tomass-MacBook-Air dev.app % cd Contents/MacOS
bosomt@Tomass-MacBook-Air MacOS % ./Trezor\ Suite
2025-01-31T13:49:18.569Z - INFO(main): Application starting
2025-01-31T13:49:18.645Z - INFO(modules): Initializing 25 modules
2025-01-31T13:49:18.648Z - INFO(@trezor/connect): Starting service
2025-01-31T13:49:18.649Z - INFO(modules): All modules initialized
2025-01-31T13:49:18.650Z - INFO(http-receiver): Starting server
2025-01-31T13:49:18.652Z - INFO(bridge): Starting (Legacy: No, Test: No, Dev: No)
2025-01-31T13:49:18.675Z - INFO(http-receiver): Server started
2025-01-31T13:49:18.693Z - INFO(process-trezord): Starting process:
2025-01-31T13:49:18.693Z - INFO(process-trezord): - Path: /Applications/dev.app/Contents/Resources/bin/bridge/trezord
2025-01-31T13:49:18.693Z - INFO(process-trezord): - Params:
2025-01-31T13:49:18.693Z - INFO(process-trezord): - CWD: /Applications/dev.app/Contents/Resources/bin/bridge
2025-01-31T13:49:18.708Z - INFO(build): Info:
2025-01-31T13:49:18.708Z - INFO(build): - Version: 25.2.0
2025-01-31T13:49:18.708Z - INFO(build): - Electron: 32.2.6
2025-01-31T13:49:18.708Z - INFO(build): - Node: v20.18.1
2025-01-31T13:49:18.708Z - INFO(build): - Commit: 8d27bcd60f50edb88369f2c0f0a1fc26ede4f5e1
2025-01-31T13:49:18.708Z - INFO(build): - Dev: No
2025-01-31T13:49:18.708Z - INFO(build): - Args:
2025-01-31T13:49:18.708Z - INFO(build): - CWD: /Applications/dev.app/Contents/MacOS
2025-01-31T13:49:18.783Z - INFO(modules): Initializing 25 modules
2025-01-31T13:49:18.790Z - WARN(auto-updater): Feed url: https://data.trezor.io/suite/releases/desktop/latest
2025-01-31T13:49:18.790Z - INFO(auto-updater): Is looking for pre-releases? (No)
2025-01-31T13:49:18.791Z - INFO(modules): All modules initialized
2025-01-31 14:49:19.122 Trezor Suite[26248:1850103] +[IMKClient subclass]: chose IMKClient_Modern
2025-01-31 14:49:19.122 Trezor Suite[26248:1850103] +[IMKInputSession subclass]: chose IMKInputSession_Modern
2025-01-31T13:49:18.841Z - INFO(main): Main window initialized - calling handshake
2025-01-31T13:49:19.552Z - INFO(@trezor/connect): Disable proxy
2025-01-31T13:49:19.553Z - INFO(auto-updater): Update checking request (manual: No)
2025-01-31T13:49:19.553Z - INFO(auto-updater): Checking for update
2025-01-31T13:49:19.554Z - INFO(request-filter): https://data.trezor.io/config/develop/config.v1.jws was allowed because data.trezor.io is in the exception list
2025-01-31T13:49:19.576Z - INFO(request-filter): https://data.trezor.io/suite/releases/desktop/latest/latest-mac.yml?noCache=1iiu9v2al was allowed because data.trezor.io is in the exception list
2025-01-31T13:49:19.578Z - INFO(request-filter): https://data.trezor.io/suite/log/desktop/develop.log?c_v=25.2.0&c_type=suite-ready&c_commit=8d27bcd60f50edb88369f2c0f0a1fc26ede4f5e1&c_instance_id=DUi8q7uBPt&c_session_id=AgLH0pZ5mQ&c_timestamp=1738331359577&c_message_id=kNT44efrSl&language=en&enabledNetworks=btc&customBackends=&localCurrency=usd&bitcoinUnit=BTC&discreetMode=false&screenWidth=1470&screenHeight=956&platformLanguages=en-US&tor=false&labeling=fileSystem&rememberedStandardWallets=0&rememberedHiddenWallets=0&theme=light&suiteVersion=25.2.0&earlyAccessProgram=false&experimentalFeatures=&browserName=electron&browserVersion=32.2.6&osName=macos&osVersion=10.15.7&desktopOsVersion=24.3.0&desktopOsName=darwin&desktopOsArchitecture=arm64&windowWidth=1410&windowHeight=919&autodetectLanguage=true&autodetectTheme=true&isAutomaticUpdateEnabled=false was allowed because data.trezor.io is in the exception list
2025-01-31T13:49:19.580Z - INFO(request-filter): https://data.trezor.io/suite/log/desktop/develop.log?c_v=25.2.0&c_type=transport-type&c_commit=8d27bcd60f50edb88369f2c0f0a1fc26ede4f5e1&c_instance_id=DUi8q7uBPt&c_session_id=AgLH0pZ5mQ&c_timestamp=1738331359580&c_message_id=4VDVSOGLF9&type=BridgeTransport&version=2.0.33 was allowed because data.trezor.io is in the exception list
2025-01-31T13:49:19.646Z - INFO(auto-updater): No new update is available:
2025-01-31T13:49:19.646Z - INFO(auto-updater): - Last version: 25.1.2
2025-01-31T13:49:19.646Z - INFO(auto-updater): - Last release date: 2025-01-21T13:53:30.719Z
2025-01-31T13:49:19.646Z - INFO(auto-updater): - Manual check: No
2025-01-31T13:49:23.044Z - INFO(request-filter): https://data.trezor.io/suite/log/desktop/develop.log?c_v=25.2.0&c_type=router%2Flocation-change&c_commit=8d27bcd60f50edb88369f2c0f0a1fc26ede4f5e1&c_instance_id=DUi8q7uBPt&c_session_id=AgLH0pZ5mQ&c_timestamp=1738331363041&c_message_id=o3ObsMJqHx&prevRouterUrl=%2F&nextRouterUrl=%2Fsettings&anchor= was allowed because data.trezor.io is in the exception list
2025-01-31T13:49:25.139Z - INFO(build): Info:
2025-01-31T13:49:25.139Z - INFO(build): - Version: 25.2.0
2025-01-31T13:49:25.139Z - INFO(build): - Electron: 32.2.6
2025-01-31T13:49:25.139Z - INFO(build): - Node: v20.18.1
2025-01-31T13:49:25.139Z - INFO(build): - Commit: 8d27bcd60f50edb88369f2c0f0a1fc26ede4f5e1
2025-01-31T13:49:25.139Z - INFO(build): - Dev: No
2025-01-31T13:49:25.139Z - INFO(build): - Args:
2025-01-31T13:49:25.139Z - INFO(build): - CWD: /Applications/dev.app/Contents/MacOS
2025-01-31T13:49:25.209Z - DEBUG(computer): Info:
2025-01-31T13:49:25.209Z - DEBUG(computer): - Platform: darwin arm64
2025-01-31T13:49:25.209Z - DEBUG(computer): - OS: macOS 15.3
2025-01-31T13:49:25.209Z - DEBUG(computer): - Manufacturer: Apple Inc.
2025-01-31T13:49:25.209Z - DEBUG(computer): - Model: Mac14,2
2025-01-31T13:49:25.209Z - DEBUG(computer): - Virtual: No
2025-01-31T13:49:25.209Z - DEBUG(computer): - CPU: Apple M2
2025-01-31T13:49:25.209Z - DEBUG(computer): - Cores: 1x8(+0) @ 2.4GHz
2025-01-31T13:49:25.209Z - DEBUG(computer): - RAM: 16.0 GB
2025-01-31T13:49:25.779Z - INFO(app): Quitting
2025-01-31T13:49:25.791Z - INFO(main): Before quit, window exists: true
2025-01-31T13:49:25.791Z - INFO(modules): Quitting all modules
2025-01-31T13:49:25.791Z - INFO(@trezor/coinjoin): Stopping (app quit)
2025-01-31T13:49:25.791Z - INFO(tor): Stopping (app quit)
2025-01-31T13:49:25.792Z - WARN(process-tor): Couldn't stop process (already stopped)
2025-01-31T13:49:25.792Z - INFO(bridge): Stopping (app quit)
2025-01-31T13:49:25.792Z - INFO(process-trezord): Stopping process
2025-01-31T13:49:25.792Z - INFO(@trezor/connect): Stopping (app quit)
2025-01-31T13:49:25.792Z - INFO(http-receiver): Stopping (app quit)
2025-01-31T13:49:25.792Z - INFO(http-receiver): Server stopped
2025-01-31T13:49:25.793Z - INFO(process-trezord): Exited, code: N/A (Stopped: Yes)
2025-01-31T13:49:26.797Z - INFO(process-trezord): Killed successfully
2025-01-31T13:49:26.797Z - INFO(modules): All modules quit, exiting

with debug

bosomt@Tomass-MacBook-Air MacOS % ./Trezor\ Suite
2025-01-31T13:49:31.306Z - INFO(main): Application starting
2025-01-31T13:49:31.379Z - INFO(modules): Initializing 25 modules
2025-01-31T13:49:31.382Z - INFO(@trezor/connect): Starting service
2025-01-31T13:49:31.383Z - INFO(modules): All modules initialized
2025-01-31T13:49:31.384Z - INFO(http-receiver): Starting server
2025-01-31T13:49:31.385Z - INFO(bridge): Starting (Legacy: No, Test: No, Dev: No)
2025-01-31T13:49:31.408Z - INFO(http-receiver): Server started
2025-01-31T13:49:31.425Z - INFO(process-trezord): Starting process:
2025-01-31T13:49:31.425Z - INFO(process-trezord): - Path: /Applications/dev.app/Contents/Resources/bin/bridge/trezord
2025-01-31T13:49:31.425Z - INFO(process-trezord): - Params:
2025-01-31T13:49:31.425Z - INFO(process-trezord): - CWD: /Applications/dev.app/Contents/Resources/bin/bridge
2025-01-31T13:49:31.439Z - INFO(build): Info:
2025-01-31T13:49:31.439Z - INFO(build): - Version: 25.2.0
2025-01-31T13:49:31.439Z - INFO(build): - Electron: 32.2.6
2025-01-31T13:49:31.439Z - INFO(build): - Node: v20.18.1
2025-01-31T13:49:31.439Z - INFO(build): - Commit: 8d27bcd60f50edb88369f2c0f0a1fc26ede4f5e1
2025-01-31T13:49:31.439Z - INFO(build): - Dev: No
2025-01-31T13:49:31.439Z - INFO(build): - Args:
2025-01-31T13:49:31.439Z - INFO(build): - CWD: /Applications/dev.app/Contents/MacOS
2025-01-31T13:49:31.516Z - INFO(modules): Initializing 25 modules
2025-01-31T13:49:31.522Z - WARN(auto-updater): Feed url: https://data.trezor.io/suite/releases/desktop/latest
2025-01-31T13:49:31.523Z - INFO(auto-updater): Is looking for pre-releases? (No)
2025-01-31T13:49:31.523Z - INFO(modules): All modules initialized
2025-01-31 14:49:31.852 Trezor Suite[26299:1850592] +[IMKClient subclass]: chose IMKClient_Modern
2025-01-31 14:49:31.852 Trezor Suite[26299:1850592] +[IMKInputSession subclass]: chose IMKInputSession_Modern
2025-01-31T13:49:31.572Z - INFO(main): Main window initialized - calling handshake
2025-01-31T13:49:32.231Z - INFO(build): Info:
2025-01-31T13:49:32.231Z - INFO(build): - Version: 25.2.0
2025-01-31T13:49:32.231Z - INFO(build): - Electron: 32.2.6
2025-01-31T13:49:32.231Z - INFO(build): - Node: v20.18.1
2025-01-31T13:49:32.231Z - INFO(build): - Commit: 8d27bcd60f50edb88369f2c0f0a1fc26ede4f5e1
2025-01-31T13:49:32.231Z - INFO(build): - Dev: No
2025-01-31T13:49:32.231Z - INFO(build): - Args:
2025-01-31T13:49:32.231Z - INFO(build): - CWD: /Applications/dev.app/Contents/MacOS
2025-01-31T13:49:32.254Z - DEBUG(modules): Loading auto-updater
2025-01-31T13:49:32.254Z - DEBUG(auto-updater): Version of application before this launch: 25.2.0, current app version: 25.2.0
2025-01-31T13:49:32.259Z - DEBUG(modules): Loading user-data
2025-01-31T13:49:32.259Z - DEBUG(modules): Loading @trezor/connect
2025-01-31T13:49:32.259Z - DEBUG(modules): Loading @trezor/coinjoin
2025-01-31T13:49:32.259Z - DEBUG(modules): Loading auto-start
2025-01-31T13:49:32.259Z - DEBUG(modules): Loaded auto-updater
2025-01-31T13:49:32.259Z - DEBUG(modules): Loaded user-data
2025-01-31T13:49:32.260Z - DEBUG(modules): Loaded @trezor/connect
2025-01-31T13:49:32.260Z - DEBUG(modules): Loaded @trezor/coinjoin
2025-01-31T13:49:32.260Z - DEBUG(modules): Loaded auto-start
2025-01-31T13:49:32.297Z - DEBUG(computer): Info:
2025-01-31T13:49:32.297Z - DEBUG(computer): - Platform: darwin arm64
2025-01-31T13:49:32.297Z - DEBUG(computer): - OS: macOS 15.3
2025-01-31T13:49:32.297Z - DEBUG(computer): - Manufacturer: Apple Inc.
2025-01-31T13:49:32.297Z - DEBUG(computer): - Model: Mac14,2
2025-01-31T13:49:32.297Z - DEBUG(computer): - Virtual: No
2025-01-31T13:49:32.297Z - DEBUG(computer): - CPU: Apple M2
2025-01-31T13:49:32.297Z - DEBUG(computer): - Cores: 1x8(+0) @ 2.4GHz
2025-01-31T13:49:32.297Z - DEBUG(computer): - RAM: 16.0 GB
2025-01-31T13:49:32.314Z - DEBUG(@trezor/connect): Add event listener DEVICE_EVENT
2025-01-31T13:49:32.314Z - DEBUG(@trezor/connect): Add event listener UI_EVENT
2025-01-31T13:49:32.314Z - DEBUG(@trezor/connect): Add event listener TRANSPORT_EVENT
2025-01-31T13:49:32.314Z - DEBUG(@trezor/connect): Add event listener BLOCKCHAIN_EVENT
2025-01-31T13:49:32.314Z - DEBUG(@trezor/connect): call init
2025-01-31T13:49:32.325Z - DEBUG(request-interceptor): net.Socket.connect - 127.0.0.1:21325
Core handleMessage {
  type: 'iframe-call',
  payload: { proxy: '', method: 'setProxy' },
  id: 1
}
Core loading method...
Core method selected setProxy
@trezor/connect handleMessage {
  event: 'RESPONSE_EVENT',
  type: 'RESPONSE_EVENT',
  id: 1,
  success: true,
  payload: { message: 'Success' },
  device: undefined
}
2025-01-31T13:49:32.326Z - INFO(@trezor/connect): Disable proxy
2025-01-31T13:49:32.353Z - INFO(auto-updater): Update checking request (manual: No)
2025-01-31T13:49:32.354Z - INFO(auto-updater): Checking for update
2025-01-31T13:49:32.355Z - DEBUG(tor): Getting status (OFF)
2025-01-31T13:49:32.355Z - INFO(request-filter): https://data.trezor.io/config/develop/config.v1.jws was allowed because data.trezor.io is in the exception list
Core handleMessage {
  type: 'iframe-call',
  payload: {
    coin: 'btc',
    request: { feeLevels: 'preloaded' },
    method: 'blockchainEstimateFee'
  },
  id: 2
}
Core loading method...
Core method selected blockchainEstimateFee
@trezor/connect handleMessage {
  event: 'RESPONSE_EVENT',
  type: 'RESPONSE_EVENT',
  id: 2,
  success: true,
  payload: {
    blockTime: 10,
    minFee: 1,
    maxFee: 2000,
    dustLimit: 546,
    levels: [ [Object], [Object], [Object], [Object] ]
  },
  device: undefined
}
Core handleMessage {
  type: 'iframe-call',
  payload: {
    coin: 'eth',
    request: { feeLevels: 'preloaded' },
    method: 'blockchainEstimateFee'
  },
  id: 3
}
Core loading method...
Core method selected blockchainEstimateFee
@trezor/connect handleMessage {
  event: 'RESPONSE_EVENT',
  type: 'RESPONSE_EVENT',
  id: 3,
  success: true,
  payload: {
    blockTime: -1,
    minFee: 1,
    maxFee: 10000,
    dustLimit: undefined,
    levels: [ [Object] ]
  },
  device: undefined
}
Core handleMessage {
  type: 'iframe-call',
  payload: {
    coin: 'pol',
    request: { feeLevels: 'preloaded' },
    method: 'blockchainEstimateFee'
  },
  id: 4
}
Core loading method...
Core method selected blockchainEstimateFee
@trezor/connect handleMessage {
  event: 'RESPONSE_EVENT',
  type: 'RESPONSE_EVENT',
  id: 4,
  success: true,
  payload: {
    blockTime: -1,
    minFee: 1,
    maxFee: 10000000,
    dustLimit: undefined,
    levels: [ [Object] ]

@bosomt
Copy link
Contributor

bosomt commented Feb 3, 2025

Any chance we can add it as startup flag ?
we already have --log-level=debug
it would be better to use --log-level=connect than enabling connect loging for every user with debug enabled

Copy link

coderabbitai bot commented Feb 3, 2025

Walkthrough

The changes modify the initialization of TrezorConnect within the IPC proxy options. Specifically, the update involves introducing the app import from the electron module. The onRequest method now calls TrezorConnect.init with an object that includes the first parameter from the params array spread into it. Additionally, a new property debug is conditionally set based on whether the command line switch log-connect is present. The overall structure and control flow of the module remain unchanged, and no alterations were made to exported or public declarations.

Suggested reviewers

  • szymonlesisz
  • martykan
  • marekrjpolak
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@mroz22
Copy link
Contributor Author

mroz22 commented Feb 3, 2025

724bd42 --log-connect maybe?

Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 7c602de and 724bd42.

📒 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.

Comment on lines +59 to +64
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',
});
Copy link

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 the log-level flag.
    • In packages/suite-desktop-core/src/modules/trezor-connect.ts, the code uses a separate log-connect flag. This introduces inconsistency and potential confusion.
  • 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 the log-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:

  1. Consider aligning with existing logging flags by using --log-level=connect instead of log-connect=true for consistency with the existing --log-level=debug flag.
  2. The string comparison with 'true' could be more flexible to accept various truthy values.
  3. 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

@mroz22
Copy link
Contributor Author

mroz22 commented Feb 3, 2025

/rebase

Copy link

github-actions bot commented Feb 3, 2025

@trezor-ci trezor-ci force-pushed the suite-desktop-connect-logs branch from 724bd42 to c5ea2cc Compare February 3, 2025 11:57
@mroz22 mroz22 merged commit 343922b into develop Feb 3, 2025
24 checks passed
@mroz22 mroz22 deleted the suite-desktop-connect-logs branch February 3, 2025 12:18
@bosomt
Copy link
Contributor

bosomt commented Feb 3, 2025

QA OK

--log-connect=true startup flag will include connect logs in console

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-project This label is used to specify that PR doesn't need to be added to a project
Projects
Status: ✅ Approved
Development

Successfully merging this pull request may close these issues.

4 participants