strongloop / modern-syslog

modern-syslog
Other
49 stars 19 forks source link

Use as reporter for Hapi.js with Good #21

Closed alainm closed 7 years ago

alainm commented 7 years ago

Please help me using modern-syslog as a reporter for Hapi.js using it's native plugin Good: https://github.com/hapijs/good Modern-syslog can be used as a stream, but I cannot figure how to connect the two.

Hi, I have spent hours on this, I have found no better logging packaged :(

rmg commented 7 years ago

From skimming through the docs for options, I see that the final stream may be a string or an instantiated stream.

From the log to console example it shows something like this:

const reporters = {
    console: [{
        module: 'good-squeeze',
        name: 'Squeeze',
        args: [{
            log: '*',
            response: '*'
        }]
    }, {
        module: 'good-console'
    },
    'stdout',         // <--- uses the string form
    ],
};

To put modern-syslog in to this instead of the console we would change it to:

const syslog = require('modern-syslog');
const syslogErr = new syslog.Stream(syslog.LOG_ERR);
const const reporters = {
    console: [{
        module: 'good-squeeze',
        name: 'Squeeze',
        args: [{
            log: '*',
            response: '*'
        }]
    }, {
        module: 'good-console'
    },
    syslogErr,         // <--- uses the stream instance
    ],
};