npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

noogger

v0.1.8

Published

Writes log files for nodejs modules/applications

Downloads

621

Readme

node-logger (noogger)

A simple logging module for node.js

Build Status

noogger is a simple featured logger module that helps you displaying 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

  • write daily log file, handy for servers, or applications that run continously
  • Forwards(prints) logging data to the console output if needed (optional)
  • En/Disable Console output with respect to log levels
  • En/Disable File output with respect to log levels
  • pretty colors in console output
  • Supported log levels (as per cisco and many other manufacturer standards): EMERGENCY(0) ALERT(1) CRITICAL(2) ERROR(3) WARNING(4) NOTICE(5) INFO(6) DEBUG(7)
  • Customize date-time format for log lines and for log file name

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:

  • consoleOutput : boolean : Wether the logs should be printed on the console output as well, or not
  • consoleOutputLevel : int or string or array : Filters what is printed to the console with respect to log levels (specify the console output log level). using int: from 0 to 7 using string: any valid log level (DEBUG, INFO, ERROR,....) using array: to allow to select multiple log levels without the constraint of order eg: ['DEBUG','ERROR','WARNING']
  • fileOutput : boolean : Wether the logs should be written to files or not
  • consoleOutputLevel : int or string or array : Filters what is written to log files with respect to log levels (works the same as consoleOutputLevel).
  • outputPath : string : define the location where the log files will be written
  • dateTimeFormat : string : specifies the Date and time format to be used inside log file for each record. refer to the date format section.
  • fileNameDateFormat: string : the date format to be used in the log files name to differentiate them (per day); you can alter this, so that it will write one file per week or month or whatever you want, refer to the date format section.
  • fileNamePrefix: string : Prepends the given string to every log file name.
  • fileNameSuffix: string : Appends the given string to every log file name.
  • customIntro: function or boolean : Just. try it by stting it to true :) or supply your own function to be called when your application starts(at least at the point where you initialize noogger)

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.