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

cplus

v2.0.1

Published

``` npm install cplus ```

Downloads

17

Readme

Console Plus

npm install cplus

Build Status

  • Adds more console log levels: fatal, error, warn, info, log, debug, trace, silly.

  • Makes the console output pretty, styled and prefixed by the log level:

    Console Output

  • Allows log level limit (option: logLevel). NOTE: This will only work with built-in transports. So if you override it with your own transport (using transport option), you have to handle the logic in there.

    // Only display log levels `warn` and more severe (`error`, `fatal`).
    cplus.install({
      logLevel: cplus.LogLevels.WARN,
    })
  • Certain log levels can optionally be left untouched (option: untouchedLogLevels).

    // Do not touch console.error() to keep clickable stack traces.
    cplus.install({
      untouchedLogLevels: [cplus.LogLevels.ERROR],
    })
  • You can also pass your own custom transport (option: transport).

    const myCustomTransportInstance = new CustomTransport()
    
    cplus.install({
      transport: myCustomTransportInstance,
    })
  • If you want to get built-in transport that is already set-up with default configuration you can use factories createBrowserTransport or createCliTransport to get transport instance (this factory does not take any arguments). This is useful if you still want to use cplus logging but you may wish to capture or modify the incoming data:

    import { createCliTransport } from 'cplus'
    
    // ...
    
    class CustomTransport {
      constructor() {
        this._cliTransport = createCliTransport()
      }
    
      logMessage(logLevel, ...args) {
        // do my own stuff here
        const cleanData = convertData(args)
    
        this._cliTransport.logMessage(logLevel, cleanData)
      }
    }
  • If you want to access built-in transports directly, you can do that. Just import transports object that contains BrowserTransport and CliTransport constructors.

  • If you need to switch from built-in transport for Logger (perhaps after initialization or right after installing cplus), you can do so by calling setTransport:

import cplus from 'cplus'

cplus.install({
  untouchedLogLevels: [cplus.LogLevels.ERROR, cplus.LogLevels.TRACE],
})

// after the installation phase, instance of logger will be avaible in browser
// like this
const logger = window.console.logger

// create your own instance of custom transport
const customTransport = new CustomTransport()

// switch from built-in transport to your custom one
logger.setTransport(customTransport)

Usage

import cplus from 'cplus'

// Plain/default installation:
cplus.install()

// Custom installation:
cplus.install({
  /* options */
})

Licence

MIT