console-mirroring

    1.0.3 • Public • Published

    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

    Install

    npm i console-mirroring

    DownloadsWeekly Downloads

    14

    Version

    1.0.3

    License

    ISC

    Unpacked Size

    6.8 kB

    Total Files

    6

    Last publish

    Collaborators

    • roccomuso