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

kttnkndy

v1.0.1

Published

kttnkndy (pronounced cotton candy) is a fancy JS logging tool.

Downloads

1

Readme

kttnkndy JavaScript Style Guide npm

kttnkndy logo

kttnkndy (pronounced cotton candy) is a logging tool that actually helps your work.

Features

  • Create differently named instances for different services.
  • Create timers to measure performance.

Usage

var kttn = require('kttnkndy')('myInstance'); // [myInstance] Initialized.

kttn.log('Hello World!'); // 16:54:41 - [myInstance] Hello World!

var myTimer = kttn.timer('myTimer'); // 16:54:42 - [myInstance] Started timer "myTimer".
doSomething(); // Run a time-consuming function...
myTimer.end(); // 16:55:42 - [myInstance] Ended timer "myTimer", took 60.663s.

Quick Start

First, we'll need to initialize a kttn instance. You should do this for every service running on the same console output.

var kttn = require('kttnkndy')('main'); // Initializes a kttn instance, logs "16:54:41 - [main] Initialized."

Basic logging and errors

Something you probably do in every project you build is logging. It's essential to debugging and making sure your project works.

kttnkndy makes it easy to differentiate between logging messages from different services.

kttn.log('Hello world!'); // Outputs: "16:54:41 - [main] Hello world!"
kttn.error('Uh-oh... Something happened...'); // Outputs: "16:54:41 - [main] Uh-oh... Something happened..." on stderr

Timers

To measure your project's performance, timers are essential. They measure how much time it took to do something.

In kttnkndy, it's easy to time things.

var myTimer = kttn.timer('myTimer'); // Creates a timer instance, outputs: "16:54:42 - [myInstance] Started timer "myTimer"."
doSomething();
var ms = myTimer.end(); // Ends the timer, outputs: "16:55:42 - [myInstance] Ended timer "myTimer", took 60.663s.". Returns milliseconds.

Documentation

Functions

newKttnInstance

newKttnInstance is the function returned on require('kttnkndy').

Example

var kttn = require('kttnkndy')('myInstance', {
  showInitializedMessage: true,
  timestampedLog: true
})

Parameters

  • instanceName - The name of the kttn instance. Appears in all log messages. (string)
  • options - A KttnOptions object.

Returns

newKttnInstance returns a KttnInstance.

kttnLog

kttnLog is the function returned on kttn.log.

Example

kttn.log('Hello World!')

Parameters

  • message - The message to log. (string)

kttnError

kttnError is the function returned on kttn.error.

This is kttnLog, but it logs the message to stderr.

kttnTimer

kttnTimer is the function returned on kttn.timer.

Example

var timer = kttn.timer('myTimer');

Parameters

  • name - The name of the timer. (string)

Returns

kttnTimer returns a KttnTimer.

kttnEndTimer

kttnEndTimer is the function returned on timer.end.

This ends the timer and logs a message with the time result.

Example

timer.end();

Returns

kttnEndTimer returns a number, the milliseconds it took between the start of the timer and the end. This value is also logged.

Objects

KttnOptions

Properties

  • showInitializedMessage - Should an "initialized" message be shown? (bool) (default: true)
  • timestampedLog - Should a timestamp be shown in all messages? (bool) (default: true)

Example

{
  showInitializedMessage: false
}

KttnInstance

Properties

Example

{
  name: 'myInstance',
  log: [function],
  error: [function],
  timer: [function],
  timestamped: true
}

KttnTimer

Properties

  • timerName - The name of the timer instance. (string)
  • startTime - The UNIX timestamp of the start time of the timer. (number)
  • end - kttnEndTimer (function)
  • log - kttnLog (function)
  • timestamped - timestampedLog from newKttnInstance's options. (bool)
  • name - The name of the kttn instance. (string)

Example

{
  timerName: 'myTimer',
  startTime: 1524411709,
  end: [function],
  log: [function],
  timestamped: true,
  name: 'myInstance'
}