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

@fusionworks/advanced-logger

v1.0.6

Published

Advanced console logger which replace console.log adding a lot more configurability.

Downloads

5

Readme

@FusionWorks/advanced-logger

GitHub package.json version npm downloads Coverage Status

Advanced logger which can replace default console but are higly customizable.

advanced-logger is an javascript solution for presenting large amount of logging tasks. The logger was designed to be extremely flexible and light; it doesn't require you to replace original console with it but its design to.

It was built for modern browsers using TypeScript.

Features

  • Handle large amount of logs by one configuration.
  • Expressive configuration for each method apart.
  • Custom styles for each method apart.
  • Custom prefix/postfix for each method apart.
  • Custom standalon configuration for unique call.

Features todo

  • AoT Compilation Support
  • Handle arrays by configuration and display them as console.table instead of console.log

Installation

To use advanced-logger in your project install it via npm:

npm i @fusionworks/advanced-logger --save

Get to some entry point at your project and init by next syntax:

import { Console } from '@fusionworks/advanced-logger';
// For nodeJs will be `const { Console } = require('@fusionworks/advanced-logger');`

console = new Console();

console.log('thats just a log');
console.warn('thats just a warn');
console.info('thats just a info');
console.error('thats just a error');
console.debug('thats just a debug');

Configuration

Console class has several configurations which are given by new Console(config) or console.update(config);

Configuration model is:

{
  public debug?: {
    public hide?: boolean,
    public css?: string,
    public prefix?: string | string[],
    public sufix?: string | string[],
  };
  public info?: {
    public hide?: boolean,
    public css?: string,
    public prefix?: string | string[],
    public sufix?: string | string[],
  };
  public log?: {
    public hide?: boolean,
    public css?: string,
    public prefix?: string | string[],
    public sufix?: string | string[],
  };
  public error?: {
    public hide?: boolean,
    public css?: string,
    public prefix?: string | string[],
    public sufix?: string | string[],
  };
  public warn?: {
    public hide?: boolean,
    public css?: string,
    public prefix?: string | string[],
    public sufix?: string | string[],
  };
  public hide?: boolean,
  public css?: string,
  public prefix?: string | string[],
  public sufix?: string | string[],
}

Here are some example of configuration you may use.

Usage

import { Console, ConfigurationModel } from '@fusionworks/advanced-logger';

const configuration: ConfigurationModel = {
  debug: {
    css: 'color: blue',
    hide: false, // default
    prefix: '[debug]',
    sufix: '[post-debug]',
  },
  info: {
    css: 'color: green',
    hide: false, // default
    prefix: '[info]',
    sufix: '[post-info]',
  },
  log: {
    css: 'color: black',
    hide: false, // default
    prefix: '[log]',
    sufix: '[post-log]',
  },
  error: {
    css: 'color: red',
    hide: false, // default
    prefix: '[error]',
    sufix: '[post-error]',
  },
  warn: {
    css: 'color: yellow',
    hide: false, // default
    prefix: '[warn]',
    sufix: '[post-warn]',
  },
  // Global configuration
  // will be used for those method which has no configuration
  hide: false, // default
  css: 'color: black',
  prefix: '[DEFAULT-PREFIX]',
  sufix: '[DEFAULT-SUFIX]',
};

console = new Console(configuration);

Override configuration

Configuration can be overrided:

  const newConfig = { log: false };
  // This will override only configuration for console
  // it means that any other configuration will be the same.
  console.update(newConfig);

  // If you want to fully override configuration you must
  console.update(newConfig, true);

Clone console instance

To create copy based on old instance of console.

  const newConfig = { log: false };
  // This will create new instance of console
  const anotherConsole = console.standalone(newConfig);

  // To override configuration of new instance
  // Better use new Console(newConfig) instead.
  const anotherConsole = console.standalone(newConfig, true);

  // Also you can use it as one-time function
  console.standalone({css: 'background: green;'}).log('Hello green world!');

Testing

You can test it out by running

  • cd demo
  • npm install
  • node index for latest released version.
    OR
  • node demo for current source code.