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

nisshi

v1.0.2

Published

A very fancy logger for JavaScript

Downloads

219

Readme

nisshi for JavaScript

A very fancy logger library for JavaScript.

logo

Navigation

Installation

npm

Install nisshi on npm:

npm i --save nisshi

then import in JavaScript:

import nisshi from 'nisshi';

From file

Download the minified JavaScript file:

wget https://codeberg.org/daysant/nisshi/raw/branch/javascript/nisshi.min.js

then import in JavaScript:

import nisshi from './nisshi.min.js'

Usage

nisshi supports various levels, toggles, and file logging.

Basic logging functions

nisshi comes with five levels of logging:

nisshi.info("Lorem ipsum dolor sit amet");
nisshi.trace(`OwO, what's ${var}?`);
nisshi.debug("A thing happened.");
nisshi.warn("JavaScript undefined jumpscare!!");
nisshi.error("Houston, we have a problem.");
nisshi.fatal("I just sharted my pants");

Fatal messages can also be supplied with an exit code.

nisshi.fatal("Segmentation fault", 139);

You can also add newlines to seperate messages:

nisshi.newline();

Multiline messages are also supported.

nisshi.info(
`Shikanoko tokotoko,
arawaru nokonoko,
tsunotsuno pyokopyoko
mitame wa onya noko?`
);

Setting different logging levels

You can set a logging level with the level setter/getter:

nisshi.info("Now you see me");
nisshi.level.info = false;
nisshi.info("Now you dont");

This also works with newlines:

nisshi.level.newline = false;
nisshi.newline(); // won't appear

They can be retrieved by simply stating the setter/getter:

if (!nisshi.level.debug) {
    nisshi.warn("Debug statements are disabled");
}

Logging to a file

nisshi can log to files. You can set it with the file setter/getter:

nisshi.file = "program.log"

and retrieved by stating it:

if (nisshi.file) {
    nisshi.info("Logging path is set")
}

The path can be changed mid-program.

nisshi.file = "first.log"
nisshi.info("File A")
nisshi.file = "second.log"
nisshi.info("File B")

Logging to a file can be disabled all together by setting it to false.

nisshi.file = false

Can be useful if you want seperate logs for different parts of the same file.

Note File logging only works in Node, as the browser does not support fs.

Contributing

nisshi is free to modify and use in almost every case (see the license). This means you can contribute towards nisshi.

If you want to see a feature added or find a bug, check out the (main branch)[https://codeberg.org/daysant/nisshi/src/branch/main] and open an issue.

Or you can clone nisshi directly via Git:

git clone https://codeberg.org/daysant/nisshi/src/branch/main

Running tests

Make sure to write and run tests before committing code. Tests can be run with:

npm i # to get mocha
npm run test

Changelog

1.0.2

  • remove the random npm installer that was there + proper linting

1.0.1

  • Initial release
  • The PATCH is 1 as opposed to 0 due to issues with npm's immutable versioning policy (due to accidentally publishing a broken package that was unpublished)

Credits

nisshi is created by daysant (Codeberg).

This library is licensed under the daysant license v2.