1.0.3 • Published 6 years ago

console-mirroring v1.0.3

Weekly downloads
31
License
ISC
Repository
github
Last release
6 years ago

console-mirroring

This project aims to provide a Real-time console mirroring on a web page.

How it works

This module extends in your node app some console functions:

  • console.log
  • console.info
  • console.warn
  • console.error

Every function extended got his own color on the web page UI.

Install

npm install console-mirroring --save

NPM

Use

Just include it in your app passing a socket.io reference, like this:

    var app = require('express')();
    var server = require('http').Server(app);
    var io = require('socket.io')(server);
    server.listen(process.env.PORT || 8080);
    require('console-mirroring')(io);

    // Every console.* will be sent to the client web UI.
    console.log('Hello World'); // white
    console.info('Hello World'); // blue
    console.warn('Hello World'); // orange
    console.error('Hello World'); // red

Client side

    <div id="#console"></div>

    <script src="https://cdn.socket.io/socket.io-1.4.3.js"></script>
	<script src="browser.console.mirror.js"></script>

    <script type="text/javascript">
        var socket = io.connect('http://' + location.host, {
            'reconnect': true,
            'reconnection delay': 50,
            'max reconnection attempts': 300
        });

        // Make sure to pass a valid socket.io obj to the init method.
        consoleMirroring.init({
            socketLib: socket,
            containerId: '#console',
            fullScreen: true,
            border: false
        });
    </script>

Optional properties:

    {
        fullScreen: true/false,  // false by default
        border: true/false       // true by default
    }

Dependencies

  • Socket.io

Author

Rocco Musolino @roccomuso

License

MIT

1.0.3

6 years ago

1.0.21

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago