πͺ΅ 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.
This plugin is designed to work alongside 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.
- π Adds a
POST /console_logroute to the dev server for capturing logs - π Automatically generates a
console.jsfile that overridesconsole.logandconsole.info - π Uses
ngrok(if available) to allow logs from remote devices - βοΈ Filters out noisy logs (like
[rspeedy-dev-server]and[HMR]) by default - π§ͺ Optional
rspeedyLogsflag to include all logs if needed
npm install relog-rsbuild-plugin --save-dev// 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]
}),
],
};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).
import 'relog-rsbuild-plugin/console.js';This script overrides
console.logandconsole.infoglobally to forward logs to the dev server.
- If
ngrok-rsbuild-pluginis installed and exposes a tunnel URL, that URL is used for logging. - A
console.jsfile is generated pointing tohttp(s)://<host>/console_log. - The script redefines
console.logandconsole.infoto send logs as JSON to the dev server. - The server receives and prints them in your terminal.
- Logs are filtered by default to hide common development spam (
[rspeedy-dev-server],[HMR]) β you can turn them back on withrspeedyLogs: true. - The server route is mounted at
/console_log. - Make sure your app loads the generated
console.jsfile.
[APP]: App launched on device
[APP]: Fetching data from API...
[APP]: { status: "ok", data: [...] }MIT