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

@tolga1452/logchu

v3.1.2

Published

Very simple and cool logger for your Node.js projects.

Downloads

15

Readme

logchu

Very simple and cool logger for your Node.js projects. Supports JavaScript and TypeScript.

Features

| Feature | | --- | | ✅ Fully customizable | | ✅ Basic logging | | ✅ Chalk support | | ✅ RGB, ANSI, Decimal, Hexadecimal support | | ✅ JavaScript & TypeScript support | | ✅ Advanced logging | | ✅ Log level support | | ✅ Custom colors | | ✅ Custom loggers | | ✅ Randomized logging | | ✅ Rainbow logging | | ✅ Config file support | | ✅ Built-in colors | | ✅ Custom logger logic support | | ✅ Log file support | | ✅ Log event support |

Installation

npm install @tolga1452/logchu

Usage

const { logger, ColorPreset, fromChalk, LogType } = require('@tolga1452/logchu');

// Basic usage
logger.info('Hello, world!');
logger.success('Hello, world!');
logger.warning('Hello, world!');
logger.error('Hello, world!');
logger.debug('Hello, world!');

// With styles and color presets
logger.info('Hello, world!', { bold: true });
logger.custom('Hello, world!', { color: ColorPreset.Magenta, italic: true, type: LogType.Debug });
logger.custom('Hello, world!', ColorPreset.Cyan);

// With chalk
const chalk = require('chalk');

logger.custom('Hello, world!', fromChalk(chalk.dim.red(' '))); // You have to use a single space character as text for chalk

Randomization

const { logger } = require('@tolga1452/logchu');

logger.random('Hello, world!', { bold: true }); // Log with random color
logger.fullRandom('Hello, world!', { inverse: true }); // Fully random log with overwrites

Advanced Logs

write Methd

const { write, ColorPreset } = require('@tolga1452/logchu');

write(
    {
        color: ColorPreset.LightGray,
        italic: true
    },
    {
        text: 'First one was default config ',
        color: ColorPreset.LightGreen
    },
    {
        text: 'this is ',
        useDefault: true
    },
    {
        text: 'awesome!',
        color: ColorPreset.LightCyan,
        bold: true
    }
);

Custom Logger Logic

const { CustomLogger } = require('@tolga1452/logchu');

const myCustomLogger = new CustomLogger({
    _logic: log => {
        console.log('Put your custom logic here.');
        console.log('This will be runned along with the default logic.');
    },
    info: { color: ColorPreset.BackgroundBlue, italic: true }
}, true); // true for overwrite default logic

Custom Colors

Supports Hexadecimal, RGB, decimal and ANSI colors.

In Your Code

const { logger } = require('@tolga1452/logchu');

logger.custom('Hello, world!', { color: '#f44747' });

From Config File

  1. Create a file named logchu.config.js in your project root.
  2. Add the following code to the file:
module.exports = {
    customColorPresets: {
        myCustomColor: '#639dff'
    }
};
  1. Use it in your code:
const { logger, userColor } = require('@tolga1452/logchu');

logger.custom('Hello, world!', userColor('myCustomColor'));

Custom Loggers

In Your Code

const { CustomLogger, ColorPreset } = require('@tolga1452/logchu');

const myCustomLogger = new CustomLogger({
    info: { color: ColorPreset.BackgroundBlue, italic: true },
    success: { color: ColorPreset.LightGreen, bold: true },
    trolley: { color: '#9b4eea', bold: true }
});

myCustomLogger.info('Hello, world!');
myCustomLogger.success('Hello, world!', { bold: false });
myCustomLogger.trolley('Hello, world!', ColorPreset.BackgroundRed);

From Config File

  1. Create a file named logchu.config.js in your project root.
  2. Add the following code to the file:
const { ColorPreset } = require('@tolga1452/logchu');

module.exports = {
    customLoggers: {
        myCustomLogger: {
            info: { color: ColorPreset.BackgroundBlue, italic: true },
            success: { color: '#80b918', bold: true },
            trolley: { color: '$custom:myCustomColor', bold: true }
        }
    },
    customColorPresets: {
        myCustomColor: '#e84118'
    }
};
  1. Use it in your code:
const { useLogger } = require('@tolga1452/logchu');

const myCustomLogger = useLogger('myCustomLogger');

myCustomLogger.info('Hello, world!');

Saving Logs

  1. Create a file named logchu.config.js in your project root.
  2. Add the following code to the file:
module.exports = {
    logFile: './logs.txt'
};

Log Events

  1. Create a file named logchu.config.js in your project root.
  2. Add the following code to the file:
const { Watcher } = require('@tolga1452/logchu');

module.exports = {
    watcher: new Watcher()
};
  1. Use it in your code:
const { logger, LogEvent } = require('@tolga1452/logchu');
const { watcher } = require('./logchu.config');

watcher.on(LogEvent.Info, log => {
    console.log('Info log event triggered:', log);
});

logger.info('Hello, world!');