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

consolebuddy

v1.2.1

Published

A flexible and customizable logging system for browser consoles.

Downloads

8

Readme

ConsoleBuddy 📋

logo ConsoleBuddy 1.2.0 is out! See what's new in ConsoleBuddy 1.2.0!

ConsoleBuddy is a flexible and customizable TypeScript library for logging system for browser consoles. It enhances the standard console logging experience by allowing developers to create and manage various log types, each with custom styles, icons, and more. With ConsoleBuddy, debugging, monitoring and creating error handlers in your web applications becomes both more manageable and visually appealing!

Getting started

General Info:

Why ConsoleBuddy Exists

In modern web development, debugging and logging are crucial for maintaining robust applications. However, default browser console logs (console.log, console.error, etc.) lack the flexibility and style needed for better organization and distinction of messages. ConsoleBuddy was created to address these limitations by:

  • Providing a more structured and visually distinguishable console logging experience.
  • Allowing developers to define custom log types with unique styles and icons.
  • Making debugging, logging, and monitoring in web applications easier, clearer, and more intuitive.

Why should you as a developer use ConsoleBuddy

🔧 Customization & Flexibility

  • Define custom log types to suit your application's needs.
  • Choose your log type's background color, text color, and even use emojis for icons.
  • Predefined log types (error, warn, info, success, etc.) are ready to use right out of the box.

👁️ Enhanced Readability

  • Visually differentiate between various log types in the console.
  • Use collapsible logs for detailed information without cluttering the console.

⚡ Ease of Integration

  • Lightweight and easy to include in any web project.
  • Works seamlessly with modern JavaScript frameworks.

How to Use ConsoleBuddy

Installation

To start using ConsoleBuddy, run the following command in your project:

npm install consolebuddy

Basic Features

Import ConsoleBuddy into your project

After installation, import the functions you need in your JavaScript or TypeScript files:

import { dynamicMessage, createNewLogType } from 'consolebuddy';

Using predefined log types

ConsoleBuddy comes with several predefined log types, such as log, error, warn, info, success, debug, system, note, and alert. You can use these directly:

// Log a success message
dynamicMessage('Operation Complete', 'Your operation was successful!', 'Success', 'success');

// Log an error message
dynamicMessage('Error', 'Something went wrong!', 'Error', 'error');

Advanced Features

Creating a Custom Log Type

You can define your own log types using createNewLogType.

Specify the background, color, and icon for your custom log type:

// Create a custom log type
createNewLogType('customLog', {
  background: '#4caf50',
  color: '#fff',
  icon: '🚀'
});

// Use the custom log type
dynamicMessage('Custom Log', 'This is a custom log message using ConsoleBuddy.', 'Custom', 'customLog');

Creating Log Messages Without a Description

In some cases, you may want to log a message without providing extra details. ConsoleBuddy makes this simple by allowing you to omit the description parameter when calling dynamicMessage() .

Example: Log a Message Without a Description To log a message without any additional description, simply skip the description parameter when calling dynamicMessage:

dynamicMessage('Simple Log Message', '', 'Log', 'log');

Or, to make it extra clear you can instead pass undefined, like this:

dynamicMessage('Simple Log Message', undefined, 'Log', 'log');

Stack Tracing made easier than ever!

(ConsoleBuddy Stac Tracing is equivillant to console.trace())

Sometimes, understanding the flow of functions in your code is extremely crucial. ConsoleBuddy helps you trace the path of your function calls with ease using stack tracing! simply trigger a dynamicMessage with the trace attribute to preform a ConsoleBuddy tracing.

Example: How to create stack tracing To log a message without any additional description, simply skip the description parameter when calling dynamicMessage:

dynamicMessage('Example Stack Trace', 'This is an example of stack tracer!', 'Trace', 'trace');

Now, we can use it inside functions as we use it when we're using regulat console.trace()!

function firstFunction() {
  secondFunction();
}

function secondFunction() {
  thirdFunction();
}

function thirdFunction() {
  dynamicMessage('Trace', 'This is a trace log.', 'Trace', 'trace');
}

firstFunction();

Customizable Default Log Types

ConsoleBuddy allows you to customize predefined log types (e.g., error, info) or add new ones using the createNewLogType function.

By default, if you try to create a log type with a name that already exists, it will NOT overwrite the original and will show a warning in the console.

However, you can force an overwrite of the existing log type without the need to modify ConsoleBuddy source code by using the forceOverwrite option in the createNewLogType function.

In that example we're force overwriting the error logType by using forceOverwrite: true.

createNewLogType('error', {
  background: '#ff0000',
  color: '#ffffff',
  icon: '🔥'
}, { forceOverwrite: true });

dynamicMessage('Critical Error!', 'This is a forced overwrite of the error log type.', 'Error', 'error');

future planned updates

Support for console.trace() Support Status

Implement console.trace() in log messages to provide stack trace information, aiding in debugging by showing the execution path that led to a specific log.

Timestamps for Logs Support Status

Add an option to include custom timestamps for each log entry, with support for different formats (e.g., HH:mm:ss, YYYY-MM-DD HH:mm:ss). This will help developers correlate logs with application events more effectively.

Custom Fonts Support Status

Introduce support for custom fonts in log messages, allowing developers to style console output to match their branding or application theme.

Grouping Logs Support Status

Enable nested logging groups using console.group() and console.groupEnd(). This will allow logs to be organized hierarchically, making it easier to follow complex processes or API calls.

Log Level Filtering Support Status

Add a setLogLevel method to control which types of logs (error, warn, info, debug) are displayed based on the current log level. This will help developers filter out unnecessary logs during different stages of development or production.

Each feature will have its own release.

More features soon.

Whats new in ConsoleBuddy

1.2.1 Support Status:

  • minor changes

1.2.0 Support Status:

  • added support for console.trace!

1.0.0 > 1.0.4 Support Status:

  • minor changes and bug fixes.
  • Please use the latest version only. latest versions provide better security and more features.

Some images and examples

Example_Images