loghooks-node

0.0.1 • Public • Published

loghooks-node

Simple helper to hook stdout, console log to remote clients, file, or custom function

Example

var hook = require('loghooks-node');
hook.stdout(hook.tlsclient(8888, 'key.pem', 'cert.pem'), AlsoPrintToStdout=false);

See the test-* files for examples

There are many logging modules out there, but you may have used console.log, or stdout in existing code, right?

You would have to go back and rework that.. OR.. Just hook stdout with this module.

Supported are:

TCP client (connect to your app remotely for live log updates over telnet)

hook.stdout(hook.tcpclient(8888), AlsoPrintToStdout=false);

TLS client (like TCP but encrypted using tls/ssl)

hook.stdout(hook.tlsclient(8888, 'key.pem', 'cert.pem'), AlsoPrintToStdout=false);

File (just write to a file)

hook.stdout(hook.file('hookedlog.txt'), AlsoPrintToStdout=false);

Uncaught (hook uncaught exceptions)

hook.uncaught(function(s){
   console.log('caught exception here.. ' + s);
});

Custom functions (use your function to handle console.log)

function myfunc(s){
  // note stdout was hooked, not stderr..
    process.stderr.write('Custom func sez: '+s);
}
 
hook.stdout(myfunc, AlsoPrintToStdout=false);

/loghooks-node/

    Package Sidebar

    Install

    npm i loghooks-node

    Weekly Downloads

    0

    Version

    0.0.1

    License

    none

    Last publish

    Collaborators

    • dpweb