Console log to terminal
npm install termlogIt also comes with a __nodejs__ REPL so you can do some basic draft code
termlog binary : npm install --save-dev termlog ( you also can install globally with npm install -g termlog )npx termlog or termlog if you install globally
import termlog from "termlog"
termlog()
`
5. You should now see log being streamed to your terminal__Note__: with this approach you might want to remove two lines above in production
By default termlog will __not__ run if it detects production mode using
NODE_ENV, but you shouldn't rely on thatI don't want to add dependencies to my project
1. Install the termlog binary : npm install -g termlog
2. Start server termlog
3. Go to your browser and open the console window
4. Copy code inside index.js file __without__ the last export line into console
5. Enter termlog() into console
6. You should now see log being streamed to your terminal__Note__: with this approach you have to do all steps 3-6 every-time you refresh your browser tab
Advanced options
With termlog command:
- --out path: Save log to file
- --port port: Change server port
- --addr addr: Change server address
- --show levels: Select log levels to display (info | warning | error | debug). Multiple levels are seperated by ,
> use .show levels while the server running to select again
With
termlog package:termlog({Debug on mobile
To be able to stream log from your app running on mobile you need to:
- Start term log with 0.0.0.0 by running npx termlog --addr 0.0.0.0
- Find your private IP address
- MacOS: run ipconfig getifaddr en0 if you're on wifi and
- Linux: run hostname -I
- Windows: run ipconfig and find in the printed result. It should be under 192.168.x.x
- Inside your project init tconfig with: termlog({host: "YOUR_PRIVATE_IP"})How it works
Termlog have 2 components:
- server.js - a websocket server to receive log message and display on terminal.
- index.js - termlog function to override default behavior of console object by capture arguments and send to websocket serverFuture release
- [ ] Install using ` tag