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

beautify-logs

v1.0.1

Published

Elegant logs for your elegant apps with many available formats and Markdown formatting.

Downloads

4

Readme

✨ Beautify Logs

This library provides to your app a set of pretty and colorful log formats with different importance levels (debug, info, warn, error, and fatal). It even gives you the opportunity to use markdown in your logs.

📥 Installation

npm

npm install beautify-logs

yarn

yarn add beautify-logs

pnpm

pnpm add beautify-logs

🖐️ Getting Started

Import the main class

const { Logger } = require('beautify-logs');

Instantiate the imported class with your own options (check their description further below)

const logger = new Logger({ ... });

Start logging

logger.debug('Lorem Ipsum dolor sit amet.');

logger.info('Lorem Ipsum dolor sit amet.');

logger.warn('Lorem Ipsum dolor sit amet.');

logger.error('Lorem Ipsum dolor sit amet.');

logger.fatal('Lorem Ipsum dolor sit amet.');

Bonus: how to use the Logger class instance in any of your app file

To do so, simply assign the logger property to the process in your index file.

Object.assign(process, {
   logger: logger
});

process.logger.debug('The logger is now usable from anywhere!');

⚙️ Logger options

You can personalize your logger by providing your own options.

1. The format

You can choose one of the many available formats (check further below). Default value is: 0

const logger = new Logger({
   format: 3
});

logger.debug('This is the third format!');
Result :

Third Format Preview

2. The message splitting

You can provide as many messages as you want at once in a single log. This option allows you to wether split those or not. Default value is: false

const logger = new Logger({
   splitMessages: true
});

logger.debug('Hello, World!', 'How is your day going?');
Result :

Message Splitting Preview

const logger = new Logger({
   splitMessages: false
});

logger.debug('Hello, World!', 'How is your day going?');
Result :

Message Splitting Preview

3. The message formatting

You can choose to wether format the messages with some Markdown (bold, italic, underline, and URL coloring) or not. Default value is: true

const logger = new Logger({
   formatMessages: true
});

logger.debug('Here is some **bold**, *italic*, __underline__, and https://example.com/');
Result :

Message Formatting Preview

const logger = new Logger({
   formatMessages: false
});

logger.debug('Here is some **bold**, *italic*, __underline__, and https://example.com/');
Result :

Message Splitting Preview

🦋 Log Formats Preview

Format No. 0

Format No. 0 Preview

Format No. 1

Format No. 1 Preview

Format No. 2

Format No. 2 Preview

Format No. 3

Format No. 3 Preview

Format No. 4

Format No. 4 Preview

Format No. 5

Format No. 5 Preview

Format No. 6

Format No. 6 Preview

Format No. 7

Format No. 7 Preview

  • Note: The colors may slightly vary according to your terminal colors.
  • More formats will come soon!

🔎 Object Inspecting

If an object is given as a message instead of a string, the library will display its whole content using util.inspect(...) method.

Example

const user = {
   fullName: 'John Doe',
   birthDate: new Date(1989, 8, 22),
   hobbies: [
      'programming',
      'sport'
   ],
   familyMembers: {
      parents: {
         mother: 'Coralie Clark',
         father: 'William Doe'
      }
   }
};

logger.info('A user was created:', user);
Result :

Object Inspecting Example