Skip to content
/ bs-email Public

📨 A proof of concept logging fueled emailer.

Notifications You must be signed in to change notification settings

rwoll/bs-email

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Bunyan Stream Email

About

A stream interface that sends email with each write through common nodemailer transporters and is meant to be used with the NodeJS logger bunyan.

Currently, the log record will simply be emailed as pretty-printed JSON text; however, in the future, the log messages will be formatted.

Example

'use strict';
const BunyanStreamEmail = require('bs-email');
const nodemailer = require('nodemailer');
const bunyan = require('bunyan');
const sendmailTransport = require('nodemailer-sendmail-transport');

// Create transporter (could be any number of the nodemailer transporters)
const transporter = nodemailer.createTransport(sendmailTransport());

// Create a stream
const emailStream = new BunyanStreamEmail(
  {
    sender: 'sender@example.com',
    recipient: 'admin@example.com'
  },
  transporter);

// Create the logger and register the stream
const log = bunyan.createLogger({
  name: 'ExampleAppLogger',
  streams: [
    {
      stream: emailStream,
      type: 'raw',
      level: 'fatal'
    }
  ]
});

// Trigger some logs! Our email stream will be written to for log events meeting
// the set level filter
log.fatal('I\'m a fatal log message.');
log.fatal('Did you get my last email?');

About

📨 A proof of concept logging fueled emailer.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published