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

@kluseg/monaco

v0.0.1

Published

Universal and colorful logging library written in TypeScript

Downloads

3

Readme

Monaco - Console logging redefined

Let's just face it. You're glued to the monitor for at least 8 hours a day of which 4 is for staring at the developer console. And yeah, you have to comment out console method calls you don't need at the moment in order to somehow navigate through this chaos. Oh, you also forgot to remove this temporary console.debug('HERE'), which floods user's console in production environment. Have you ever wondered if there is something that could release you from this pain? The answer is "Monaco".

npm install --save @kluseg/monaco

What does it actually doing?

Monaco can be imported with ease!

import Monaco from '@kluseg/monaco';

Monaco can make your logs look great again!

const logger = new Monaco();
logger.success('Looking gooood!').send();

Monaco can take care of conditional logging!

Just switch Monaco's verbosity level and appropriate logs would be displayed.
enum LogLevel {
  errorsOnly = 0,
  QAtests = 1,
  full = 2,
}

const logger = new Monaco(LogLevel.errorsOnly);
// This won't be shown because Monaco's verbosity is set to "errorsOnly" or simply 0
logger
  .success("Looking good!")
  .when(LogLevel.full)
  .send();

// This is displayed no matter what
logger
  .error("Fatal!")
  .send();

// Callback will be executed when provided function returns "true"
logger.when((verbosity: number) => {
  return verbosity >= LogLevel.QAtests && userDidSomething();
}, () => {
  logger
    .warn("User did something")
    .send();

  logger
    .notice("Notice me senpai!")
    // Show additional console.trace!
    .withTrace()
    .send();
})

Monaco can display additional group badge for added readability!

const cartLogger = new Monaco(2, 'Cart');

// Displays badge [Cart | Info]
cartLogger.info('Cart module initialized').send();

// Displays badge [Cart @ src/modules/cart.ts | Warn]
cartLogger.warn('User cart is empty!').locatedAt('src/modules/cart.ts').send();

cartLogger
  // Creates new Monaco instance with given parameters
  .$create(3, 'Cart supervisor')
  // Displays badge [Cart @ src/modules/cart.ts | Error]
  .error('Unable to locate user cart!')
  .send();

// And again, and again...
const catalogLogger = new Monaco(1, 'Catalog');

Monaco is customizable.

const cartLogger = new Monaco(2, 'Cart', {
  error: {
    background: 'red',
    foreground: 'rgb(0,0,33)',
  },
  success: {
    background: 'black',
    foreground: '#fff',
  },
});

And if you are lazy or integrating Monaco into existing project you can use it as a drop-in replacement for console (you get only colours though).

Monaco.$patchConsole();

Future plans

v1.0

  1. Complete documentation.
  2. Demo page.
  3. Proper tests.
  4. Node.js support.

v1.x

  1. Multi-channel support (ability to save logs to file, send to slack channel, etc.).

Thanks for checking it out!

Feel free to request new features! :)