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

nodejs-logging-libary

v1.0.1

Published

https://github.com/cedy88/NodeJS-Logger

Downloads

5

Readme

📃 NodeJS-Logger

Welcome to this Project, its a small project ive made for my own projects in NodeJS.

a good looking Logging Libary with some cool features & animations

I may continue updating this, maybe not, idk

Project Banner

📥 Installation

#Installing using NPM:
>npm i nodejs-logging-libary

#Clone The Github repo:
>git clone https://github.com/cedy88/NodeJS-Logger.git

Example:

const {Logger, presets, create_error, colors} = require('nodejs-logging-libary');

// Define colors for the logger
var { foreground_colors, background_colors, text_formatting } = colors;

const custom_logger_settings = {//Custom Settings for the logger
    b_display_time: true,
    s_display_mode: 'icon_and_tag', // icon_only, tag_only, icon_and_tag
    s_time_format: 'de-DE',
    s_time_zone: 'Europe/Berlin',
    box_settings: {
        border_color: 'white',
        border_style: 'double',
        valign: 'center',
        padding: 0,
        marginLeft: 1,
        b_display_time: false, //Make sure the text is not too short, otherwise the time wont be displayed in the box
    },
    loading_animation: presets.loading_animation_presets.braille_dots,
    progress_bar: presets.progress_bar_presets.dashed,
    divider: presets.dividers.dot,
};

function task_todo() {
    return new Promise((resolve) => {
        setTimeout(() => {
            resolve();//call resolve() to indicate that the task is done
        }, 10);
    });
}

async function main(){
    // const logger = new Logger(custom_logger_settings); // Custom settings
    const logger = new Logger(); // Default settings

    // Displays a simple message in a box with default styling.
    logger.box('Welcome!');

    // Displays a message in a customized box.
    logger.box('Watupp\nThis is a box message', { border_color: 'green', border_style: 'doubleSingleRounded', padding: 2, marginLeft: 1, b_display_time: false});
    
    // Logs a general message to the console.
    logger.log("This is a log message!");

    // Logs a warning message, indicating a potential issue.
    logger.warn("This is a warning!");

    // Logs a success message, indicating a successful operation.
    logger.success("This was a success!");
    
    // Logs an informational message.
    logger.info("This is an info!");
    
    // Logs an error message, without the position of the code where this log was called at
    logger.errorEx("This is an error message!");

    // Logs an error message with the position of the code where this log was called at
    // Parameters:
    // - error(create_error("message")) | You have to call the create_error function to get the error message
    logger.error(create_error("This message faild to send!"));

    // Get integer input from the user
    await logger.get_int_input("How old is you?");

    // Get integer input from the user with a specified range of allowed 
    await logger.get_int_input("Rate this repo from 1-10", 1, 10);

    // Get string input from the user
    await logger.get_string_input("Whats your name?");

    // Logs user activity
    // Parameters:
    // - action: The action being logged 
    // - username: The username of the user performing the action 
    // - request: The request, its necacary to display the IP Adress!
    // - is_admin_activity: Indicates whether the action was done by an admin or user.
    logger.user_activity("Create User", "Alibaba1337", "request", false);
    logger.user_activity("Delete User", "AdminSenpai69", "request", true);

    // Logs user activity with unlimited additional custom arguments
    // Parameters:
    // - action: The action being logged
    // - username: The username of the user performing the action.
    // - request: The request, its necacary to display the IP Adress!
    // - is_admin_activity: Indicates whether the action was done by an admin or user.
    // - additional args: Additional arguments to include in the log message.
    logger.user_activityEx("Create Auction", "AdminSenpai69","request", true, `AuctionID: ${foreground_colors.yellow + "78346875463785634"}`);

    // Adds space in the log for better readability same as "console.log('\n');"
    logger.space();

    // Ask a yes/no question
    // Prompts the user with a yes/no question and waits for a Yes/No response.
    const is_user_sure = await logger.bool_question("are you sure?");

    // Adds space in the log for better readability
    logger.space();

    // Displays a progress bar
    // Indicates the progress of a running task.
    await logger.progress_bar(task_todo, "Updating Network adapters..");

    // Indicates that a task is in progress displaying a loading circle/symbol for a specified duration(milliseconds).
    await logger.loading_circle("Updating Profile..", 5000);
};
main();