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

nocol

v1.1.3

Published

styled nodejs console logger

Downloads

10

Readme

nocl

Styled nodejs console logger

Installation

npm i nocol

Usage

import nocl, { Nocl } from "nocol";

nocl.log("Hello world!");

Default export: nocl - an instance of Nocl class

Create new instance

const nocl2 = new Nocl(options);
nocl2.log("Hello world from nocl2!");

Class init options / properties

You can also modify the properties directly to change the styling without creating new instance

| name | type | default | description | | ---------------- | ------- | ------------ | -------------------------------------- | | symbolPrefix | object | | Symbol to be prepend to theme's symbol | | symbolPostfix | object | | Symbol to be append to theme's symbol | | encloseSymbol | boolean | true | Enclose symbol with square brackets | | useChalkTemplate | boolean | false | Color text with chalk template | | theme | object | DefaultTheme | Logging theme style object |

Default theme

| name | color | symbol | symbolColor | | ------- | ------- | ---------------- | ----------- | | log | #b6b5b5 | | #b6b5b5 | | info | #105ae4 | i | #105ae4 | | error | #ea4141 | x | #ea4141 | | success | #2cc22c | ✓ | #2cc22c | | warning | #e7a414 | ! | #e7a414 | | ts | #b6b5b5 | {curr_timestamp} | #636363 | | plus | green | + | green | | minus | red | - | red | | comment | gray | # | gray |

For color or symbolColor value, you can pass hex color or chalk ForegroundColor

themes

Examples

Modifying theme

This will merge into current instance theme

nocl.info("default theme");
const theme = {
  info: {
    symbol: "info",
    symbolColor: "#074880",
  },
};
nocl.theme = theme;
nocl.info("modified theme");
// OR
const nocl3 = new Nocl({
  theme,
});
nocl3.info("modified theme from nocl3");

modified_info_theme

Modifying theme: ts

Change timestamp display

nocl.ts("default theme: ts");
nocl.theme = {
  ts: {
    // type LocalesArgument
    locales: undefined,
    // type DateTimeFormatOptions
    options: {
      hour12: true,
      timeStyle: "medium",
    },
  },
};
nocl.ts("modified theme: ts");

modified_ts_theme

Using symbolPrefix

nocl.log("without symbolPrefix");
nocl.symbolPrefix = {
  symbol: "1/10",
};
nocl.log("with symbolPrefix");

symbolPrefix

Using symbolPostfix

nocl.log("without symbolPostfix");
nocl.symbolPostfix = {
  symbol: "username",
};
nocl.log("with symbolPostfix");

symbolPostfix

Using encloseSymbol

nocl.info("with encloseSymbol");
nocl.encloseSymbol = false;
nocl.info("without encloseSymbol");

encloseSymbol

Using useChalkTemplate

This will fallback to chalk if there was an error coloring using template

nocl.log("{yellow without using chalk template}");
nocl.useChalkTemplate = true;
nocl.log("{yellow using chalk template}");

useChalkTemplate

Using session log

nocl.startSession(filepath, options); // createWriteStream
nocl.log("hello");
nocl.endSession();

sessionLogs


Check tests

TODO

  • [x] session logging

Changelog

  • 1.1.3
    • fixed chalk template
  • 1.1.2
    • added new theme "comment"
  • 1.1.1
    • added object support for session log
  • 1.1.0
    • added session logging
  • 1.0.2
    • stable version