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

rf-log

v1.0.0

Published

Simple NodeJS logging lib - no dependencys. Colored console.log or log to files. Default logging functions: info, success, waring, error. Custom functions can be added. Display prefix and time for the logs.

Downloads

235

Readme

rf-log

Simple and Ready logging lib - no dependencys.

npm install rf-log

Example 1

log-simple example

let log = require("rf-log").start("[SYSTEM-XY]");

log.success("Use the default functions here.");
log.info("The mainPrefix before is usefull - tells who loggs");
log.warning("Optionals use 'time' option");
log.error("short logs are nice - icons are shorter than words like 'error'");
log.critical("same as 'error', but also throws an Error and stops your app");

Example 2

log-simple example

var log = require("rf-log");

log.info('simple log');
log.withTime.success('log with time');
log.options.mainPrefix = '[SYSTEM-XY]';
log.success('log with prefix, several args', {'hello': 'world'});

Second prefix for libs

This helps to find the origin of a message faster

log-simple example

// NOTE: we assume this is a lib, and rf-log was already started in another file with the mainPrefix '[yourProcess]'


// start the logger and tell it the name of your lib
var log = require('rf-log').prefix('[DB-module]')


// no need mention `DB Module` again
log.success('connected')
log.info('receiving data')
log.error('connection refusing')

Log to a file

var log = require(rf-log);

log.options.logFilePath = __dirname +  "/log.txt";
log.success("this works", {"hello": "world"});

Options

var options = require(rf-log).options;
// the object is in every `require(rf-log)` present and looks like:
{
   mainPrefix: '',
   time: false,
   timeLocale: 'en-US',
   timeOptions: { year: 'numeric', month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric' },
   logFilePath: '',
   carriageReturn: true
}

Docs of time options

The lib uses Date.toLocaleString to create a time log. https://stackoverflow.com/questions/3552461/how-to-format-a-javascript-date

Docs of color options

http://stackoverflow.com/questions/9781218/how-to-change-node-jss-console-font-color

How the lib works - creation of the strings

Each string is built in the following pattern:

prefix + mainPrefix + secondPrefix + time + argumentsToLog

Development and Testing

npm install

To be able to run grunt-eslint. Run a test script and eslint with:

npm test

Legal Issues

  • Licenese: MIT
  • Author: Felix Furtmayr