@juntoz/azure-function-logger-papertrail
Version:
Quick logger that enables the function to log to the default logger (console) and also to papertrail
43 lines (35 loc) • 1.04 kB
Markdown
# azure-function-logger-papertrail
Quick logger that enables the function to log to the default logger (console) and also to papertrail
# how to use it?
Install it
```
npm install @juntoz/azure-function-logger-papertrail
```
Instantiate it
```
const Logger = require('@juntoz/azure-function-logger-papertrail');
async function main_azfunc(ctx) {
var papertrailConfig = {
host: 'PapertrailHost',
port: PapetrailPort,
app: 'PapertrailAppName'
};
// initiate the logger and send the papertrail config and the official logger
ctx.llog = new Logger(papertrailConfig, ctx.log);
// execute the function business logic
try
{
// ...
ctx.llog.debug(`debugging`);
// ...
ctx.llog.info(`informing`);
} catch (err) {
ctx.llog.error(`error found`);
throw err;
} finally {
// make sure to end the logger for each call
ctx.llog.end();
}
}
module.exports = main_azfunc;
```