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

wolverine

v0.1.4

Published

Useful library for server-side logging

Downloads

11

Readme

WolverineJS

Build Status

Useful library for server-side logging

Install WolverineJS

npm install wolverine

Usage

Instantiate a new WolverineJS object

var Wolverine = require('wolverine');

var logger = new Wolverine([Wolverine.<LEVEL>], [options]); //For levels and options check the sessions below

Log it!

logger.<LEVEL>('Title', 'Hi, I\'m %s and I\'m awesome', 'WolverineJS');

Instantiating and logging

You can instantiate a WolverineJS object in four ways: Default level (Wolverine.ALL) and options (show time and print to the terminal)

var logger = new Wolverine();

}


Logging with 3 or more parameters will follow the [util.format](http://nodejs.org/api/util.html#util_util_format_format) signature

## Default levels

* `Wolverine.ALL` Logs everything
* `Wolverine.VERBOSE` Informal message
* `Wolverine.DEBUG` Messages to help debugging the app
* `Wolverine.INFO` Informational message
* `Wolverine.WARN` Warning condition
* `Wolverine.ERROR` An error ocurred
* `Wolverine.FATAL` System is unusable
* `Wolverine.OFF` Logs nothing

## Options

* `output` (default: Nothing)
    * If ommited, print to the terminal
    * `String` Path to a file where the logs will be writen
    * `Stream` Log messages will be writen to the stream
* `printTime` Show time in the beginning of each line (default: true)
* `printStack` If an Error object is passed to be logged, print its error stack (default: false). This flag can also be passed when a log method is called
* `printLevel` If the level name must be printed before the message (default: true)
* `printFileInfo` If the file and line number must be logged (default: false)
* `driver` If you want to write the output to an API or service, you can use a driver. See below.

### Driver

The `driver` option is an object with two attributes, `lib` and `config`.

The first one must be a class, that receives two parameters in the constructor: a WolverineJS logger, and the
`config` attribute you've passed in the `driver` option.

This class must have an instance method called `write`. This method receives two parameters,
the first is the log message in its "default" format (with the color codes, that you can remove using
the `wolverineObj.chalk.stripColor(message)` method from the WolverineJS instance that comes in
the first parameter of the constructor, and the second is an object with the information
in case you want to make your own format inside your driver.

This second parameter will have the following attributes:

* `title` The title of the message, if any
* `message` The message logged
* `level` The name of the level
* `date` The Date object of the time it was logged
* `file` The file the log came from
* `line` The line of the file the log came from
* `error` The error object if it was logged an Error

If you disabled one of this options (e.g. { printStack: false }), the attribute won't be on the object.

You can see an example of the implementation of a driver in the [wolverinejs-stream](https://github.com/talyssonoc/wolverinejs-stream/blob/master/index.js) package.

## API

* `logger.<levelName>()` Check the session `Instantiating and logging`
* `logger.setLevel(Wolverine.<LEVEL>)` Set the logger to the given logging level
* `logger.getLevel()` Returns the current logging level
* `logger.addLevel(level, [newLevelOptions])` Adds a new level to the logger (see below)
* `logger.outputStream` The stream WolverineJS writes to

## Options to add a new level

* `priority` Priority to the new level. Must be a WolverineJS level or a number (default: Wolverine.ALL)
* `color` Foregroung color of the output. (default: white, see the colors below)
* `bg` Background color of the output (default: transparent, see the colors below)
* `underline` If the output must be underlined (default: false)
* `bold` If the output must be bold (default: false)

### Colors

* `red`
* `green`
* `yellow`
* `blue`
* `magenta`
* `cyan`
* `white`
* `gray`
* `black`