https://github.com/nanofuxion/relog-rsbuild-plugin
πͺ΅ Capture console logs from your LynxJS app and view them directly in your terminal β designed for use with the LynxJS Native App Framework and `rsbuild`.
https://github.com/nanofuxion/relog-rsbuild-plugin
Last synced: 5 months ago
JSON representation
πͺ΅ Capture console logs from your LynxJS app and view them directly in your terminal β designed for use with the LynxJS Native App Framework and `rsbuild`.
- Host: GitHub
- URL: https://github.com/nanofuxion/relog-rsbuild-plugin
- Owner: nanofuxion
- License: mit
- Created: 2025-04-09T03:16:51.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-04-09T03:19:41.000Z (8 months ago)
- Last Synced: 2025-04-09T04:23:23.470Z (8 months ago)
- Language: TypeScript
- Homepage:
- Size: 15.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-rstack - relog-rsbuild-plugin
README
# relog-rsbuild-plugin
> πͺ΅ Capture console logs from your LynxJS app and view them directly in your terminal β designed for use with the **LynxJS Native App Framework** and `rsbuild`.
This plugin allows you to intercept `console.log()` and `console.info()` calls from your LynxJS app running on a device or emulator and send them back to the `rsbuild` dev server where they're printed in your terminal. It's especially useful for debugging native apps where logs might not show up in your local console.
---
> β οΈ **Disclaimer:** This README and plugin were generated with the help of AI and may contain errors or outdated assumptions.
> π‘ I'm **not affiliated with LynxJS or its maintainers** β this project was built independently for use within the LynxJS ecosystem.
>
> π **Pull requests are welcome!** If something doesnβt work or could be improved, feel free to open a PR.
---
## π Related Plugin
This plugin is designed to work **alongside** [`ngrok-rsbuild-plugin`](https://www.npmjs.com/package/ngrok-rsbuild-plugin). It uses the ngrok tunnel URL to forward logs from remote devices when testing on real hardware.
Make sure youβre using both together for the best experience.
---
## β¨ Features
- π Adds a `POST /console_log` route to the dev server for capturing logs
- π Automatically generates a `console.js` file that overrides `console.log` and `console.info`
- π Uses `ngrok` (if available) to allow logs from remote devices
- βοΈ Filters out noisy logs (like `[rspeedy-dev-server]` and `[HMR]`) by default
- π§ͺ Optional `rspeedyLogs` flag to include all logs if needed
---
## π Installation
```bash
npm install relog-rsbuild-plugin --save-dev
```
---
## π§ Setup
```ts
// rsbuild.config.ts or index.ts
import { pluginRelog } from 'relog-rsbuild-plugin';
export default {
plugins: [
pluginRelog({
rspeedyLogs: false, // set to true if you want to see all logs including [rspeedy] and [HMR]
}),
],
};
```
---
## π Output
This plugin will generate a file called `console.js` in the same directory as the plugin.
You should load this file into your app's entry point (or however your framework handles native-side injection of JavaScript code).
```js
import 'relog-rsbuild-plugin/console.js';
```
> This script overrides `console.log` and `console.info` globally to forward logs to the dev server.
---
## π§© How it Works
1. If `ngrok-rsbuild-plugin` is installed and exposes a tunnel URL, that URL is used for logging.
2. A `console.js` file is generated pointing to `http(s):///console_log`.
3. The script redefines `console.log` and `console.info` to send logs as JSON to the dev server.
4. The server receives and prints them in your terminal.
---
## π Notes
- Logs are filtered by default to hide common development spam (`[rspeedy-dev-server]`, `[HMR]`) β you can turn them back on with `rspeedyLogs: true`.
- The server route is mounted at `/console_log`.
- Make sure your app loads the generated `console.js` file.
---
## π§ͺ Example Output
```bash
[APP]: App launched on device
[APP]: Fetching data from API...
[APP]: { status: "ok", data: [...] }
```
---
## License
MIT