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

colorogger

v1.3.6

Published

A simple colorful logger. Both for browser and node-server. Easy to report and record.

Downloads

5

Readme

colorogger

npm downloads license GitHub top language semantic-release action-release codecov Package Quality

A simple colorful logger. Both for browser and node-server. Easy to report and record.

releases and changelog

Demo

server demo

server demo

browser demo

browser demo

Getting Started

install

npm i colorogger

server

const colorogger = require('colorogger');
const logger = new colorogger();

logger.log('log');
logger.info('info');
logger.debug('debug');
logger.warn('warn');
logger.error('error');
logger.success('success');
logger.fail('fail');
logger.tip('tip');
logger.stress('stress');

browser (with webpack)

const colorogger = require('colorogger/lib/client');
const logger = new colorogger();
logger.success('message');

Options

color

Enable colored log.

  • type: Boolean
  • default: true

timeStamp

Enable time stamp.

  • type: Boolean
  • default: true

stringify

Make log stringify and remove breaks.

  • type: Boolean
  • default: false

print

Enable logger print log to console.

  • type: Boolean
  • default: true

level

Enable logger log to console by level grade.

  • type: Number
  • default: 0

default levels grades:

  • 0: debug
  • 1: log, tip
  • 2: info, success
  • 3: warn, stress
  • 4: error

timeTemplate

Format time stamp.

  • type: String
  • default: '{{YYYY}}/{{MM}}/{{DD}} {{hh}}:{{mm}}:{{ss}}.{{mss}}'

wrapIcon

Format icon log text.

  • type: Function
  • default: (icon) => \[${icon}]``

wrapTag

Format meta key log text.

  • type: Function
  • default: (tag, key) => \[${tag}]``

meta

Extra log info.

  • type: Object
  • default: undefined

Example:

const logger = new colorogger({
  timeStamp: false,
  meta: {
    guid: 'guid_abc'
  }
});

logger.log('log text');
// console output: [.] [guid_abc] log text

transport

Resive message object.

  • type: Function
  • default: null

Example:

const logger = new colorogger({
  meta: {
    guid: 'guid_123',
  },
  transport(msg) {
    console.log(msg);
  }
});

logger.success('log text');
// msg.content: ['log text']
// msg.flag: 'success'
// msg.grade: 1
// msg.guid: 'guid_123'
// msg.level: log
// msg.time: 1599215203843

Api

config(options)

Set logger config.

  • param [Object] options: constructor options

Example:

const logger = new colorogger();

logger.config({
  meta: {
    guid: 'guid_123',
  },
  transport(msg) {
    console.log(msg);
  }
})

logger.log('log text');
// msg.content: ['log text']
// msg.flag: ''
// msg.grade: 1
// msg.guid: 'guid_123'
// msg.level: log
// msg.time: 1599215203843

fork(options?)

Clone instance.

  • param [Object] options: constructor options

Example:

const logger = new colorogger({
  meta: {
    guid: 'guid_123',
  },
  transport(msg) {
    console.log(msg);
  }
});
const forkLogger = logger.fork();

forkLogger.log('log text');
// msg.content: ['log text']
// msg.guid: 'guid_123'
forkLogger.success('success text');
// msg.content: ['success text']
// msg.guid: 'guid_123'

method(name, options?)

Extend a method for logger instance.

  • param [String] name: method name
  • param [Object] options: method options
    • param [String] options.level: Method log level. Optional value: ['debug', 'log', 'info', 'warn', 'error'].
    • param [String] options.flag: Method flag name, will be appended to transport msg property.
    • param [String] options.color: Method color, use it will ignore theme color.

Example:

const logger = new colorogger({
  transport(msg) {
    console.log(msg);
  }
});

logger.method('intro', {
  level: 'info',
  flag: 'intro',
  color: '#ff9501',
});

logger.intro('intro text');
// msg.content: ['intro text']
// msg.flag: 'intro'
// msg.level: 'info'

theme(options)

Custom color setting.

  • param [Object] options: theme options
    • param [Object] options.colors: Configure the color of the method output log.
      • param [String] options.colors[name]: color value
    • param [Object] options.icons: icon options
      • param [Object] options.icons[name]: Configure the icon for the method output log.
        • param [String] options.icons[name].icon: icon string
        • param [String] options.icons[name].color: icon color

Example:

const logger = new colorogger({
  transport(msg) {
    console.log(msg);
  }
});

logger.method('intro', {
  level: 'info',
  flag: 'intro',
});

logger.theme({
  colors: {
    intro: '#ff9501',
  },
  icons: {
    intro: {
      icon: 'i',
      color: '#00ff00',
    }
  }
});

logger.intro('intro text');

intro demo

destroy()

Destroy instance.