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

pretty-js-log

v1.1.0

Published

A light logging package for Node.js and Bun applications. Features file logging and beautiful console output.

Downloads

72

Readme

Pretty-js-log 📝

Node.js CI npm version npm downloads License: MIT

A lightweight and colorful logging package for Node.js and Bun applications. Makes your console output beautiful and saves logs to files!

Features

  • Colorful console output
  • File logging support
  • Multiple log levels (info, warn, error, debug)
  • Support for both Node.js and Bun
  • JSON object / Array formatting
  • Custom IDs for tracking (like process ID)
  • Timezone-aware timestamps

Installation 🚀

# Using npm
npm install pretty-js-log
# Using bun
bun install pretty-js-log

Quick Start 🎯

const { logFactory } = require('pretty-js-log');

// Create a basic logger
const logger = logFactory({});

// Log some messages
logger('Hello World');
logger.info('This is an info message');
logger.warn('Warning! Something needs attention');
logger.error('Oops! Something went wrong');
logger.debug('Debug information');

Output 🎑

Pretty JS Log Demo

Advanced Usage 🔧

Save Logs to File

const logger = logFactory({
    path: './logs/app.log',  // Logs will be saved here
    id: process.pid          // Add process ID to logs
});

logger('This will be saved to the file too!');

Logging Objects

const data = {
    user: 'john',
    age: 25
};

logger('User data:', data);  // Objects are automatically formatted

Disable Console Output

If you want to write logs only to file without console output, use the toStdout option:

const logger = logFactory({
    path: './logs/app.log',
    toStdout: false    // Logs will only be written to file
});

logger('This will only appear in the log file');
logger.info('Silent logging to file');

Output Examples 🎨

When you run your logs, they'll look something like this in the console:

[2024-03-15 10:30:45] - [id:1234] - Hello World
[2024-03-15 10:30:46] - [id:1234] - This is an info message
[2024-03-15 10:30:47] - [id:1234] - Warning! Something needs attention

Contributing 🤝

Feel free to open issues and submit PRs! This is an open-source project and we welcome contributions.

License 📄

MIT License - feel free to use this in your projects!

Todo 📋

  • [x] Support logging into a file
  • [ ] Add support daily logs
  • [ ] File logging rotation based on file size or on dates.
  • [ ] Add support for external logging API's endpoints.

Author 👨‍💻

Belguinan Noureddine

GitHub: https://github.com/belguinan