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

qb-log

v1.1.0

Published

Yet another logging package

Downloads

7

Readme

qbLog

Yet another console logger. Extra simple basic usage.

Install

npm install qb-log

Usage

This module provides pure console logging for console applications and/or development.

// import and use sysLog preset.
const qbLog = require('qb-log')('sysLog');

// 20:15:00 INFO      Normal operation.
qbLog.info('Normal operation.');

// 20:15:00 WARN      Error incoming.
qbLog.warn('Error incoming.');

Presets

qbLog contains 3 default presets:

  • basic enabled by default, contains only empty printer,
  • sysLog follows https://en.wikipedia.org/wiki/Syslog#Severity_level ,
  • simple has 4 basic methods: error, warn, info and debug.

To use a preset, use the qbLog as a function, passing the preset name string as the only parameter. Methods from this preset will be available globally. Using a preset does not remove previous presets, but merely add its printers to the list.

// require qbLog
const qbLog = require('qb-log');

// add methods from the sysLog preset.
qbLog('sysLog');

Custom printers

Custom printers can be defined by adding them to the qbLog. They will be available globally.

const qbLog = require('qb-log');

qbLog._add('example', {
  prefix: 'MY_PREFIX',
  formatter: qbLog._chalk.gray,
  showTime: false
});

//          MY_PREFIX This will be example message
qbLog.example('This will be example message');

Definition of a printer consists of 3 properties. Each of them is optional.

  • prefix='' - string, kind of namespace, that will be printed before the actual message
  • showTime=true- boolean, specifies if the current time should be printed at the beginning of the line
  • formatter=(text)=>text- this function will be passed the prefix string, which can be modified. However the length of the string should not be modified, as this would break the indentation of the messages. qbLog itself uses the chalk module, that colorizes font or background of the formatter.

Custom presets

If neither sysLog nor simple suits You, instead of passing preset name, a dictionary of printer definitions can be passed.

const qbLog = require('qb-log');

qbLog({
  info: {
    prefix: 'INFO',
    formatter: chalk.cyan,
    showTime: true
  },
  debug: {
    prefix: 'DEBUG',
    formatter: chalk.green,
    showTime: false
  }
});

qbLog.info('Some info');
qbLog.debug('Some debug');

Using a preset does not remove previous presets, but merely add its printers to the list.

Removing loggers

If You want to use sysLog preset, but You don't want to use emergency or You want to redefine it, you may simply remove it, and add new definition that will suit You.

const qbLog = require('qb-log');

qbLog('sysLog')._remove('emergency');