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

consolelog

v2.1.3

Published

Cross-Browser console.log() Wrapper

Downloads

68

Readme

Console.log wrapper

Safe, clear console logging for every browser

Log to the console — even legacy browsers without a console. Just pass any data to log() and you'll see it printed clearly and well-structured in the console.

If the browser doesn't have a console, Firebug Lite will load. You can pass any variable type: strings, objects, arrays, functions, etc.

Demo: patik.github.io/console.log-wrapper

Installation

npm: npm install consolelog

Bower: bower install consolelog

Or just download consolelog.js and reference it in your page with a <script> tag.

Usage

Use log() wherever you want to write to the console.

AMD with RequireJS

Consolelog.js is AMD-compliant and supports Common JS:

require(['consolelog'], function(log) {
    log('It works!');
});

Settings

You can change some optional preferences by passing an object to log.settings(). The defaults are shown below.

log.settings({
    lineNumber: true,
    group: {
        label: 'Log:',
        collapsed: false
    }
});
  • lineNumber (Boolean)
    • Whether to append the actual line number to each log. Not supported by all browsers.
  • group (Boolean or object)
    • Groups the arguments for each log together
    • collapsed: true will collapse each group (in browsers that support collapsing)
    • label: "some string" sets the label or name for the groups
    • Simply setting group: true is a shorthand way of selecting the defaults

Detail Print

This is an optional plugin to provide help information about the data that is being logged, especially in IE and older browsers. Just include consolelog.detailprint.js along with consolelog.js.

Firebug, WebKit's Developer Tools, and Opera's Dragonfly print useful, interactive items to the console. For example:

console.log(
    "Here's a string",
     3.14,
     {"alpha": 5, "bravo": false},
     document.getElementById('charlie'),
     new Date()
);

Results in:

Firebug running in Firefox

Some browsers that have a primitive console — one that does not expand arrays, does not link DOM elements to the source code, only prints objects as [object Object] rather than listing their properties, etc.

IE8 without Detail Print

Some cannot accept multiple arguments to a single console.log call. This includes IE 7/8/9/10, iOS 5 and older, and Opera 11 and older, among others.

Using the detailPrint companion plugin, special objects are presented in a more readable manner.

IE8 with Detail Print

Demo

patik.github.io/console.log-wrapper

Documentation

patik.com/blog/complete-cross-browser-console-log

License

Console.log-wrapper is released under three licenses: MIT, BSD, and GPL.