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

logan

v0.0.2

Published

Mini template system for the console and colors

Downloads

104

Readme

Logan

Logan is a mini template system for the console and colors.

It allows to cleanly separate content from style and create beautiful logging functions.

Example

Let's say you want to write a logging function that says hello.

// Without Logan
function hello(arg) {
  console.log('Hello'.bold.green + ' : ' + arg.cyan);
}

// With Logan
var hello = logan.create('Hello : %', 'bold.green . cyan')

hello('world');

Usage

var logan = require('logan');

set

This is the most useful method of logan. It lets you define all your templates in one place.

logan.set({
  info: ['info : %', 'yellow'],
  warn: ['warn : %', 'orange'],
  omg : ['omg  : %', 'rainbow']
});

logan.info('some info');

Notice how easy it is to see what all your logging functions will output.

Also, with set your module users can easily theme logs:

// Overriding omg to be... more OMG!!!
logan.set({
  omg: ['OMG : % !!!', 'red . . red']
});

create

Returns a logging function.

var info = logan.create('info : %', 'yellow');
info('some text');

compile

Returns a function which returns a string when called.

var info = logan.compile('info : %', 'yellow');
console.log(info('some text'));

Syntax

  • % is used for string replacement.
  • {} lets you define blocks.
  • . means default style.
  • styles can be chained (example: bold.underline.red).

{} usage:

// for example, instead of writing this:
var foo = logan.create('some long green string', 'green green green green');

// using {} you can write
var foo = logan.create('{some long green string}', 'green');

About the name

Since there's a templating engine called hogan and this one is about logging, it was called logan.

More

If you want to see how Logan can be used in another project, you can have a look at ShoutJS.