Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/davidgilbertson/isolog
Send node console messages to the client
https://github.com/davidgilbertson/isolog
Last synced: 13 days ago
JSON representation
Send node console messages to the client
- Host: GitHub
- URL: https://github.com/davidgilbertson/isolog
- Owner: davidgilbertson
- License: mit
- Created: 2015-07-19T10:26:26.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-08-01T08:56:32.000Z (over 9 years ago)
- Last Synced: 2023-08-04T17:21:33.004Z (over 1 year ago)
- Language: JavaScript
- Size: 145 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# isolog
Send node console messages to your browser's console.The idea behind isolog is simple: take `console.log()` messages in node and send them to your browser's console.
This gives you easy access to logs that otherwise might be a pain to get to.It also has the benefit of easy-to-navigate collapsible object trees that browsers give you in their consoles. And pretty colors!
The console message type will be preserved, so if you `console.error('bup bow')` in node, you will get a nice red `console.error('bup bow')` in the browser.
## Using The Thing
This is meant for apps that use express 4.For ES2015:
```javascript
import isolog from 'isolog';
```
or old school:
```javascript
var isolog = require('isolog');
```### On the Server
Isolog works by creating a route and listening for a get request from a client to start sending logs. And so, when you init the server you must pass it a reference to your express app.
```javascript
isolog.initServer(yourExpressApp);
```### On the Client
In code that will run on the client:
```javascript
isolog.initClient();
```If your app is isomorphic and code could run on the server AND on the client that's fine, the `init()` methods will be ignored if not running in the right environment.
## On/Off switch
By default, messages will not be shown, but once isolog is imported/required and initialised,
you can type `isolog.stopListening()` and `isolog.stopListening()` to turn on/off logging to the browser.
Your setting is saved in localStorage for next time.## Browser Support
Isolog uses `EventSource` which means it only works in cool browsers.