|
| 1 | +This guide covers debugging the Chipmunk application, including logs and component-specific procedures |
| 2 | + |
| 3 | +## Debugging Procedures |
| 4 | + |
| 5 | +### Frontend Components |
| 6 | + |
| 7 | +The Chipmunk frontend consists of multiple components, each with a different debugging method. |
| 8 | + |
| 9 | +#### Debugging Electron App |
| 10 | + |
| 11 | +To debug the Electron `holder` application, located at `{CHIPMUNK_ROOT}/application/holder`, a debug session can be invoked directly from VS Code or any debugger that supports its launch configurations. |
| 12 | + |
| 13 | +A standard launch configuration object must be added to your debugger's settings. This configuration should point to the Electron executable and the application's entry point. |
| 14 | + |
| 15 | +```json |
| 16 | +{ |
| 17 | + "type": "node", |
| 18 | + "request": "launch", |
| 19 | + "name": "Debug Electron", |
| 20 | + "runtimeExecutable": "${workspaceRoot}/application/holder/node_modules/.bin/electron", |
| 21 | + "program": "${workspaceRoot}/application/holder/src/app.ts", |
| 22 | + "outFiles": ["${workspaceRoot}/application/holder/dist/**/*.js"] |
| 23 | +} |
| 24 | +``` |
| 25 | + |
| 26 | +Before starting each debug session, you must build the application with the development CLI tool via: |
| 27 | + |
| 28 | +```sh |
| 29 | +cargo chipmunk build app |
| 30 | +``` |
| 31 | + |
| 32 | +#### Debugging Client |
| 33 | + |
| 34 | +The application `client`, located at `{CHIPMUNK_ROOT}/application/client`, is a standard web application that you can debug using the built-in **Chromium Developer Tools**. |
| 35 | + |
| 36 | +**1. Opening Developer Tools** |
| 37 | + |
| 38 | +You can open the developer tools in several ways: |
| 39 | + |
| 40 | +* **Menu:** Select `Chipmunk` -> `Developing` -> `Toggle Developer Tools`. |
| 41 | +* **Shortcut:** Press **Ctrl + Shift + I**. |
| 42 | +* **Environment Variable:** Set `CHIPMUNK_DEVELOPING_MODE=true` before launching the application. |
| 43 | + |
| 44 | +**2. Using the Debugger** |
| 45 | + |
| 46 | +Once the developer tools are open, you can: |
| 47 | +* Inspect `console.log()` output in the **Console** tab. |
| 48 | +* Set breakpoints in the source code under the **Sources** tab, located at `webpack:///./src/`. |
| 49 | + |
| 50 | +#### Debugging Communication Libraries |
| 51 | + |
| 52 | +Chipmunk uses several shared libraries to facilitate communication between the Rust backend and the frontend components. |
| 53 | + |
| 54 | +You can debug these libraries using the same VS Code workflow as the Electron `holder`. However, because these libraries are copied into the `holder`'s `node_modules` directory during the build process, you'll need to use the specific debug paths listed below. |
| 55 | + |
| 56 | +* **`platform`**: Provides shared type definitions for frontend projects. Debug at `{CHIPMUNK_ROOT}/application/holder/node_modules/platform`. |
| 57 | +* **`ts-bindings`**: Includes type definitions for Rust-to-Electron communication. Debug at `{CHIPMUNK_ROOT}/application/holder/node_modules/rustcore/ts-bindings`. |
| 58 | + |
| 59 | +---- |
| 60 | + |
| 61 | +### Rust Backend |
| 62 | + |
| 63 | +The recommended methods for debugging the Rust backend are print-based debugging and structured logging. |
| 64 | + |
| 65 | +You can use Rust's standard printing macros for immediate feedback during development. For more persistent and configurable diagnostics, the backend uses a logging framework, which is the primary method for monitoring the application's behavior. |
| 66 | + |
| 67 | +The configuration for this logging system is detailed in the next section. |
| 68 | + |
| 69 | +---- |
| 70 | + |
| 71 | +## Logs and Configuration Files |
| 72 | + |
| 73 | +Checking the log output is the first step in diagnosing most issues. Chipmunk's log files and their configurations are located within the Chipmunk home directory. |
| 74 | + |
| 75 | +### Log Files |
| 76 | + |
| 77 | +* `chipmunk.log`: Logs for the Chipmunk Electron frontend. |
| 78 | +* `chipmunk.indexer.log`: Logs for the Chipmunk Rust backend (indexer). |
| 79 | +* `chipmunk.updater.log`: Logs for the Chipmunk updater binary. |
| 80 | +* `chipmunk.launcher.log`: Logs for the application during backend initialization. |
| 81 | + |
| 82 | +### Configuration Files |
| 83 | + |
| 84 | +Backend logging is configured using the [log4rs](https://docs.rs/log4rs/latest/log4rs/index.html) crate. To adjust log levels or other settings, modify the relevant YAML files. |
| 85 | + |
| 86 | +* `log4rs.yaml`: Configuration for the Rust backend. (Note: The first line of this file is used for version control and should not be changed.) |
| 87 | +* `log4rs_updater.yaml`: Configuration for the updater tool. |
0 commit comments