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

ausgabe

v1.0.0

Published

Tiny logger with zero defaults

Downloads

93

Readme

ausgabe

Build Coverage Status

Tiny logger with zero defaults.

ausgabe in action

Contents

Description

ausgabe is designed to output user relevant log messages to the console or to a custom stream. It's lightweight, customizable and perfect for tools that need simple, yet beautiful log messages.

Install

npm install ausgabe

Usage

Basic

import { createLogger } from 'ausgabe'

const instance = createLogger({
	info: {
		color: 'blue',
		badge: 'ℹ',
		label: 'info',
	},
})

instance.info('Hello world')

Advanced

import figures from 'figures'
import { createLogger } from 'ausgabe'

const instance = createLogger(
	{
		info: {
			color: 'blue',
			badge: figures.info,
			label: 'info',
		},
		warn: {
			color: 'yellow',
			badge: figures.warning,
			label: 'warn',
			stack: false,
		},
		error: {
			color: 'red',
			badge: figures.cross,
			label: 'error',
		},
	},
	{
		indention: 7,
	}
)

instance.info('Hello world')
instance.info('%s %s', 'Hello', 'world')
instance.warn(new Error('Logs error without the stack'))
instance.error(new Error('Logs error with the stack'))

Nested

ausgabe supports nested logger instances.

import { createLogger } from 'ausgabe'

const instance = createLogger({
	requests: createLogger({
		get: {
			color: 'magenta',
			badge: '↗',
			label: 'get',
		},
		post: {
			color: 'magenta',
			badge: '↗',
			label: 'post',
		},
	}),
})

instance.requests.get('http://example.com')
instance.requests.post('http://example.com')

Streams

ausgabe streams to process.stdout by default, but also allows custom writable streams.

import { Writable } from 'node:stream'
import { createLogger } from 'ausgabe'

const stream = new Writable({
	write: (chunk, encoding, callback) => {
		console.log(chunk.toString())
		callback()
	},
})

const instance = createLogger({
	info: {
		color: 'blue',
		badge: 'ℹ',
		label: 'info',
		streams: [stream],
	},
})

instance.info('Hello world')

API

Usage

import { createLogger } from 'ausgabe'

const instance = createLogger({
	info: {
		color: 'blue',
		badge: 'ℹ',
		label: 'info',
	},
})
import { createLogger } from 'ausgabe'

const instance = createLogger(
	{
		info: {
			color: 'blue',
			badge: 'ℹ',
			label: 'info',
		},
	},
	{
		indention: 6,
	}
)

Parameters

  • types {Object} Methods of the logger.
    • color {?String} Color of the log. Must be supported by chalk. Defaults to blue.
    • badge {?String} Icon to log along with the message. Using figures is recommended. Defaults to .
    • label {?String} Label to log along with the message. Defaults to info.
    • stack {?Boolean} Determines if the stack of an error should be logged. Defaults to true.
    • streams {?Array} Writable streams to which the data is written. Defaults to [process.stdout].
  • options {?Object} Options.
    • indention {?Integer} Aligns log messages with a custom indention.

Returns

Instance API

Usage

instance.info('Hello world')
instance.info('%s %s', 'Hello', 'world')

Parameters

  • message {String} Message containing zero or more substitution strings.
  • substitutions {?...*} Data with which to replace substitution strings within message.

Miscellaneous

Donate

I am working hard on continuously developing and maintaining my projects. Please consider making a donation to keep the project going strong and me motivated.

Related

  • signale - Highly configurable logging utility

Links