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

@leisurelink/skinny-loggins

v1.3.0

Published

The loggin module for Leisurelink

Downloads

6

Readme

Skinny Loggins

Skinny Loggins

The logger of your dreams.

Setting it up

  • npm i -S @leisurelink/skinny-loggins
// src/logger.js
import createLoggins from '@leisurelink/skinny-loggins';
const settings = {
  // Console: { /* are defaulted */ },
  // Logstash: { host: '', port: 28777 }
}
export default createLoggins(settings);
// src/magicbus.js
import nameLogger from './path/to/logger';
const logger = nameLogger('magicbus');

logger.info('Message Sent'); // MM/DD/YYYY HH:mm:ss UTC info: magicbus: "Message Sent"

Logging levels

These are the current logging levels:

  • silly - 1
  • debug - 2
  • verbose - 3
  • info - 4
  • warn - 5
  • error - 6

logger.log() is a special case where you can specify the level to which you should log.

logger.log('debug', 'Here is my debug message');
logger.log('info', 'Here is my info message');
// ....

logger.silly('Here is my silly message');
logger.debug('Here is my debug message');
logger.verbose('Here is my verbose message');
logger.info('Here is my info message');
logger.warn('Here is my warn message');
logger.error('Here is my error message');

Adding and removing transports

Adding defaults is simple. The only caveat is that currently you can only add supported transports.

var createLoggins = require('@leisurelink/skinny-loggins');
var logger = createLoggins();

// create an http transport
var transport = {
  host: 'http://some.url'
};
logger.add('http', transport);

// remove
logger.remove('http');

Transports and their defaults

If you new up a logger but don't specify a transport for it to log on, these are the defaults.

Console

Defaults

{
  level: 'info',
  silent: false,
  colorize: true,
  timestamp: true,
  json: true,
  stringify: true,
  humanReadableUnhandledException: true,
  showLevel: true,
  stderrLevels: [ 'error', 'debug' ]
}

logstash

The logstash information is not defaulted as this should be specified from the environment. The properties required are:

  • host
  • port -- this will default to 2877

Defaults

{
  host: '<specified host>', // Required
  port: 28777,
  logstash: true,
  ssl_enable: false,
  rejectUnauthorized: false,
  strip_colors: false
}

File

Defaults

{
  level: 'info',
  filename: 'logs.log',
  maxsize: 5242880,
  maxFiles: 5,
  json: true,
  eol: '\n',
  logstash: true,
  showLevel: true,
  options: { flags: 'a' }
}

consumeFrom

Many of LeisureLink's modules use an event logging pattern to publish events for any logger to consume. One example of this is @leisurelink/skinny-event-loggins. The consumeFrom method is for convenience in integrating these log events into your logging configuration. The consumeFrom expects a component argument with an on function that can be used to subscribe to log events. These events should have this structure:

{
  kind: 'info',
  message: 'howdy',
  namespace: 'component',
  err: new Error('Badness')
}

Example

// src/logger.js
import createLoggins from '@leisurelink/skinny-loggins';
import component from './configured-component';
const settings = {
  // Console: { /* are defaulted */ },
  // Logstash: { host: '', port: 28777 }
}
let logger = createLoggins(settings);
logger.consumeFrom(component);
export default logger;

// src/component.js
import createEventLogger from '@leisurelink/skinny-event-loggins';
let logger = createEventLogger('component');
export default {
  work: () => { logger.info('Work started'); },
  on: (ev, handler) => { logger.on(ev, handler); }
};