View on GitHub

Noogger

A simple and lightweight NodeJs logging library.

Download this project as a .zip file Download this project as a tar.gz file

GitHub license Build Status

NPM

Node-logger

Noogger is a featured logger module that helps you writing logs to the console with log levels and pretty colors as well as writing logs files in a clean an organized way. No need to implement the logging mechanism for your node applications anymore.

Installing

Install it locally in your project or globally:

npm install noogger
npm install -g noogger

Features

Usage

Basic (with default parameters)

var log = require('noogger');
...
...
log.emergency("This is an EMERGENCY!!! THE WORLD IS COLLAPSING");
log.alert("OMGGGG!");
log.critical("This is getting critical!");
log.error("Erro 0x04512 Failed to initialize the initialization module");
log.warning("something is wrong");
log.notice("Hey! have you noticed This?!");
log.info("Hello World! Booting..");
log.debug("something Happened!");

The log file will look like this

28-04-2016 20:16:45.5 [WARNING] something is wrong
28-04-2016 20:16:45.5 [ERROR] Failed to initialize the...
28-04-2016 20:16:45.5 [DEBUG] something Happened!
28-04-2016 20:17:06.6 [ERROR] telnet socket closed

With custom options

var logParams = {
    consoleOutput : true,
    consoleOutputLevel: ['DEBUG','ERROR','WARNING'],

    dateTimeFormat: "DD-MM-YYYY HH:mm:ss.S",
    outputPath: "logs/",
    fileNameDateFormat: "DDMMYYYY",
    fileNamePrefix:"myApp-"
};

var log = require('noogger').init(logParams);

or

var log = require('noogger');

var logParams = {
    consoleOutput : true,
    consoleOutputLevel:'DEBUG',

    dateTimeFormat: "DD-MM-YYYY HH:mm:ss",
    fileNameDateFormat: "YYYY-MM-DD",
    fileNamePrefix:"myApp-",
    outputPath: "myLogs/"
};


log.init(logParams);

Default Parameters:

    consoleOutput : true,
    consoleOutputLevel: 7, 

    fileOutput: true,
    fileOutputLevel: 7, 

    outputPath: "logs/",
    fileNameDateFormat: "DDMMYYYY",
    dateTimeFormat: "DD-MM-YYYY HH:mm:ss.S",

    fileNamePrefix:"",
    fileNameSuffix:"",
    customIntro: null

Parameters:

Date and Time formatting

The formating is based on the moment.js library, since it is the one used. So please refer to this page.

Submit any issue or request to the github page.