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

stumpy

v0.7.1

Published

The Kickass Logger

Downloads

333

Readme

Stumpy - The Kickass Logger! Build Status

bitHound Score Coverage Status License

Dependency Status devDependency Status NPM

Features

  • Highly Configurable
  • Module based Log Names
    • Different module can be given a name to make it easier to find the culprit
  • Buffered Output
    • Allows you to ship the logs off to the local sawmill or whittle a cat out of them
    • Buffers are currently, per instance
  • Customizable Log Format
    • Standard output across all parts of your application
  • Schemas Based on Environments
  • NodeJs Only (sorry browser people)
    • Groups (pretty trees O^O)
    • Colors (double rainbows!)
    • Optional All Logs Synchronise
      • Warning: current version errors are sent to stdout NOT stderr
    • All Logs with Trace Information

In the Year 3000... (Future Features)

  • [/] Improve code quality
    • [ ] Create test framework
      • [ ] Spawn a process to run the tests and compare the output
      • [ ] Use examples as first set of tests
    • [x] Add code coverage (istanbul + coveralls)
    • [x] Add static analysis of code
  • [ ] A String version of the Customizable Log Format
  • [ ] Custom Log Type (eg. stumpy.cheese({shape:'block',color:'yellow'}))
  • [ ] Customizable Log Format per Log Type
  • [ ] Transports for both NodeJs and Browser
  • [ ] Fix NodeJs Logs Synchronise to send output errors using stderr (small buffer?)
  • [ ] Global and per instance Buffers

NPM

$ npm install stumpy

Bower

$ bower install stumpy

Even a Cat can do it

var stumpy = Stumpy();

stumpy.log("look for prey");
stumpy.info("sleep %f hours", 8.62);
stumpy.warn("kill %d mice in a day", 26);
stumpy.error("miss target");

Stumpy(options)

The first argument can be either an options Object or a name string followed by an options object. The all options have defaults.

  • name - String used to when displaying a log. Default: "".
  • env - String used to determine schema to use. which Default: "dev".
  • replaceConsole - Boolean to enable/disable replace the console global object with Stumpy. Default: false.
  • getTrace - Boolean to enable/disable capture the trace info for each log. Default: false.
  • showTrace - Boolean to enable/disable display of the trace info on each log. If this is set to true, getTrace will be set to true. Default: false.
  • showDateTime - Boolean to enable/disable display of the date and time on each log. Default: false if Broweser, true if NodeJS.
  • showLogId - Boolean to enable/disable display of the log id. The Id's are unique for each log per session, when the browser/server restarts the Id is reset. Default: false.
  • showLogType - Boolean to enable/disable display of the log type ('log', 'warn', 'error', 'info', 'trace', 'group', or 'groupEnd'). Default: false.
  • syncLogs - Boolean to enable/disable display of the synchronous logs. Warning: current version errors are sent to stdout NOT stderr. Default: false.
  • display - Boolean or Object. If set to true, all display options are set to true. The Object is a key:value map of all the logging types. Default: { log: true, info: true, warn: true, error: true, trace: true, group: true, groupEnd: true }
  • formatFunc(log<Object>, logInstanceOptions<Object>) - The Function used to format the logs when getBuffer, onHandlers.addLog and onHandlers.delLog is called or on all log output. Default: built in function for server and browser.
  • dateStringFunc(date<Date Object>) - This Function formats the data object to a string for logging. Default: built in DateString function.
  • onHandlers - An Object. See Event Handler Options
  • colors - An Object. See Colors Options
  • group - An Object. See Group Options
  • buffer - An Object. See Buffer Options
  • schema - An Object. See Schema Options

Functions

  • log(...) - Add/display a log. See console.log Options
  • warn(...) - Add/display a warning. See console.warn Options
  • error(...) - Add/display a error. See console.error Options
  • info(...) - Add/display a info. See console.info Options
  • trace(...) - Add/display a trace. See console.trace Options
  • group([name]) - Add/display a group. Optional name (default: group).
  • groupEnd([name]) - Add/display a groupEnd. Optional name (default: same name as group).
  • clearBuffer() - Clears the in memory buffer.
  • getBuffer() - Returns an Array of Strings after running each log thought the buffer.formatFunc. Warning browser users: getBuffer() may not return expected results unless you include the sprintf library.
  • getRawBuffer() - Returns the raw buffer (Array of Objects) with all the captured data.
  • printBuffer() - Prints each log in the buffer using the formatFunc.
  • setEnv() - Sets the current environment and applies the schema.
  • getOptions() - Returns all current options (including schema) with environment applied.
  • setOptions(options) - Merges/applies options on current options, if env is set it will applied the environment schema.

Colors Options

See Cli-Color for color values The all options have defaults.

  • log - String or Cli-Color Object. Default: "whiteBright"
  • info - String or Cli-Color Object. Default: "blue"
  • warn - String or Cli-Color Object. Default: "yellow"
  • error - String or Cli-Color Object. Default: "red"
  • trace - String or Cli-Color Object. Default: "magenta"
  • group - String or Cli-Color Object. Default: "green"
  • groupEnd - String or Cli-Color Object. Default: "green"

Group Options

Used to generate the Group Trees for NodeJS The all options have defaults.

  • autoIndent - Boolean value enabling/disabling Group Trees. Default: true
  • indent - Object containing the string parts used to the Group Tree for NodeJS

Buffer Options

Used to configure the buffer. The all options have defaults.

  • size - Integer size of the log buffer. A 0 size will disable the buffer. When the limit is reached and a new log is add stumpy will remove the oldest log. Default: 0.
  • formatFunc(log<Object>, logInstanceOptions<Object>) - The function used to format the logs when getBuffer is called. If you wish to get the unformatted buffer use getRawBuffer. Default: null.
  • getTrace - Boolean to enable/disable capture of trace info on each log. Default: false.
  • showTrace - Boolean to enable/disable show trace info on each log. getTrace will be set to true if this is set to true. Default: false.
  • deepCopy - Boolean to enable/disable deep copy of objects stored in the buffer. The default is false to consume less memory, however objects are referenced so they could change from the original log. Default: false.

Schema Options

Used to configure the environment schemas. This is an object of environments, default: dev,stage, and prod. When an env string is set, all keys in the matching schema key are applied over all other options in the base options. The all options have defaults.

  • dev - An Object for the dev environment. Default: display: { log: true, info: true, warn: true, error: true, trace: true, group: true, groupEnd: true }.
  • stage - An Object for the stage environment. Default: display: { log: false, info: false, warn: true, error: true, trace: true, group: true, groupEnd: true }.
  • prod - An Object for the prod environment. Default: display: { log: false, info: false, warn: false, error: true, trace: true, group: false, groupEnd: false }.

Event Handler Options

The all options have defaults of no handlers.

  • addLog(logStr<String>, logObj<Object>) - A Function that will be called when a log is added. It will call the function formatting the logStr using options.formatFunc. Default: null.
  • delLog(logStr<String>, logObj<Object>) - A Function that will be called when a log is deleted from the Buffer. It will call the function formatting the logStr using options.formatFunc. Default: null.
  • addBuffer(logStr<String>, logObj<Object>) - A Function that will be called when a log is added. It will call the function formatting the logStr using options.buffer.formatFunc. Default: null.
  • delBuffer(logStr<String>, logObj<Object>) - A Function that will be called when a log is deleted from the Buffer. It will call the function formatting the logStr using options.buffer.formatFunc. Default: null.

Examples

Browser

NodeJS

License

MIT: what else?

Full license go go go! »

Blah blah blah... Tests

Mocha

$ npm test

Karma

$ npm run-script test-browser