Update README.md

This commit is contained in:
Quang Ngoc 2021-08-29 14:50:10 +07:00 committed by GitHub
parent a22c2361b7
commit 84323c6c57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,12 +2,12 @@
Bring browser console to your terminal Bring browser console to your terminal
### What it does ### What it does
termlog send the browser console log to your terminal. termlog send the browser console log to your terminal
It also comes with a __nodejs__ REPL so you can do some basic draft code It also comes with a __nodejs__ REPL so you can do some basic draft code
### When to use it ### When to use it
- While you developing your front-end app and you have to switch back and forth between IDE and browser. - While you developing your front-end app and you have to switch back and forth between IDE and browser
- When you test app on mobile and need to check log. (See [Debug on mobile](#debug-on-mobile)) - When you test app on mobile and need to check log. (See [Debug on mobile](#debug-on-mobile))
# How to use it? # How to use it?
@ -24,9 +24,9 @@ termlog()
``` ```
5. You should now see log being streamed to your terminal 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. __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 that. By default termlog will __not__ run if it detects production mode using `NODE_ENV`, but you shouldn't rely on that
## I don't want to add dependencies to my project ## I don't want to add dependencies to my project
1. Install the `termlog` binary : `npm install -g termlog` 1. Install the `termlog` binary : `npm install -g termlog`
@ -36,10 +36,10 @@ By default termlog will __not__ run if it detects production mode using `NODE_EN
5. Enter `termlog()` into console 5. Enter `termlog()` into console
6. You should now see log being streamed to your terminal 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. __Note__: with this approach you have to do all steps 3-6 every-time you refresh your browser tab
## Advanced options ## Advanced options
With `tconsole` command: With `termlog` command:
- `--out path`: Save log to file - `--out path`: Save log to file
- `--port port`: Change server port - `--port port`: Change server port
- `--addr addr`: Change server address - `--addr addr`: Change server address
@ -47,9 +47,9 @@ With `tconsole` command:
> use `.show levels` while the server running to select again > use `.show levels` while the server running to select again
With `tconsole` package: With `termlog` package:
`tconsole({ `termlog({
host: "localhost", host: "localhost",
port: 3456 port: 3456
})` })`
@ -64,9 +64,9 @@ To be able to stream log from your app running on mobile you need to :
- Inside your project init tconfig with: `termlog({host: "YOUR_PRIVATE_IP"})` - Inside your project init tconfig with: `termlog({host: "YOUR_PRIVATE_IP"})`
## How it works ## How it works
Tconsole have 2 components: Termlog have 2 components:
- [server.js](cli.js) - a websocket server to receive log from browser and display it - [server.js](cli.js) - a websocket server to receive log message and display on terminal.
- [index.js](index.js) - tconsole package to import in your front end app. This package will override the default behavior of console object and send log to the server - [index.js](index.js) - termlog function to override default behavior of `console` object by capture arguments and send to websocket server
## Future release ## Future release
- [ ] Install using `<script/>` tag - [ ] Install using `<script/>` tag