Log mailer for (Node) JS. Aggregate your log/error mail from all over your app and send it when you want.

Short description

Think of the following scenario: There are several events in your app and you want to be noticed about them via email. Well, if you have one notification, then you have one email. That’s fine. But what if you have lots of notifications over runtime, thrown by functions scattered all over your app? Then you would have to aggregate all those notifications to a (log) file and send it when your app run is finished. Lots of loggers are able to write into files. But what if you want to have a well formatted html email? Then you can use logmailer. :)

Where to find

logmailer @ github

The “Why”

In the context of the side project I am responsible for the development and operation of several web scrapers that run a few times a day and load website data, process it and write it into databases. As it is my “side” project I do not have too much time for monitoring and reporting. But: since the apps are an important part of the software behind the ML based fund, a high stability and transparency is required.

  • we need a well structured report sent by e-mail to our group e-mail address
  • we need to be notified via e-mail at our private e-mail addresses if there were serious incidents in an app execution while the e-mail also has to be well structured so that the most important information can be captured quickly
  • the report needs to be aggregated from several places all over the app


Using npm:

How to use

Set up the logmailer (initially)

Create a file to create and configure the logmailer (e.g. logmailer.js). Make sure to export the logmailer itself and your chapters.

Chapter class

Chapter is a single chapter object

  • @param name — chapters name e.g. "Summary"
  • @param hasCount — (optional, default is false) set to true if you want to count how often you added content to the chapter (good for errors or warnings)
  • @param color — (optional, default is "black") use colors to colorize headlines (you can use hex, rgb, rgba, color codes etc. but it is important that the email client can display the color correctly)

Recipient class

Recipient a single recipient object

  • @param emailAddress
  • @param getsEmailOnlyIfChaptersNotEmpty — (optional) array of chapters e.g. [chapters.errors], the recipient will get the email only if there is at least 1 logged error
  • @param canOnlySeeChapters — (optional) array of chapters e.g. [chapters.summary, chapters.errors], the recipient can only see the summary and the logged errors

Use the logmailer

In all your other files you can simply import your chapters and the logmailer and use them.

Send the mail

Reset your chapters

Format objects or arrays of objects as html tables

Nice solution for Node JS

index.js or server.js


Managers view

Firefighters view

Full view (all chapters)





Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store