Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nodelogger

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nodelogger

Log Library for Node.js

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

NodeLogger.js

Log Library for Node.js

Build Status

Overview

This library enables the followings in Node.js Application.

  • Show log message on console
  • Record log
  • Send emergency mail

Usage

It is required that Nodemailer is installed.

$ npm install nodemailer

and,

$ echo "export NODE_PATH='/usr/local/lib/node_modules/'" >> ~/.bashrc

Constructor

var NodeLogger = require('./NodeLogger.js');

// Log file path
var log = 'error.log';

// for sending mail
var settings = {
    service : 'Gmail',
    auth    : {
        user : 'sample@gmail.com',
        pass : 'xxxxxx',
        port : 25
    }
};

// Create the instance of NodeLogger
var nodeLogger = new NodeLogger(log, settings);

In the case of not sending mail,

var NodeLogger = require('./NodeLogger.js');

// Log file path
var log = 'error.log';

// Create the instance of NodeLogger
var nodeLogger = new NodeLogger(log);

API

Show log message on console

In the case of showing log message on console.

var message = 'showLog';  // Log message
var lineNo  = 22;         // Line number
var method  = 'error';    // This method is console object

nodeLogger.showLog(message, lineNo, method);

Record log

In the case of recording log message in log file.

var message = 'showLog';  // Log message
var lineNo  = 23;         // Line number

nodeLogger.appendLog(message, lineNo);

Send emergency mail

In the case of sending emergency mail.
Please refer to Nodemailer for details.

var options = {
    to      : 'sample@gmail.com',
    subject : 'NodeLogger TEST',
    html    : 'sendMail',
    from    : 'node-ninja'
};

// This callback is executed when sending mail is successful.
var successCallback = function(result) {
    console.dir(result);
};

// This callback is executed when sending mail failed.
var errorCallback = function(result, error) {
    console.dir(result);
    console.dir(error);
};

nodeLogger.sendMail(options, successCallback, errorCallback);

Keywords

FAQs

Package last updated on 15 Jun 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc