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

logbone

v1.2.3

Published

Better Logging with Logbone.

Downloads

13

Readme

Checkout Logbone's Homepage

Logbone

Logbone is a dead simple utility written with javascript for javascript apps. Why Logbone? Simple! Logbone makes console logging effortless. Quickly and easily create named loggers so you know exactly where console output is coming from. Identify environments, tests and improve log filtering with prefixes. Control the global logging level with the flip of a switch or override it for any logger.

Don't leave confusing console outputting just sitting around anymore. And no more tedious commenting and uncommenting logging lines before going to production. Logbone is here to be your bare-bones logging solution.

Getting Started

Using Logbone is easy. Simply download it from Github or install it with Bower:
bower install logbone --save-dev

Then, add Logbone to your HTML with a script tag. Make sure you put Logbone's script include before other scripts and code that utilize Logbone.

<script type="text/javascript" src="Logbone.js"></script>

That's it! You're ready to begin using Logbone. On start-up Logbone will initialize and assign a reference to itself on the global namespace. Now you are ready to grab a logger and go.

var logger = Logbone.getLogger('My_Very_First_Logger');
logger.info("I promised myself I wasn't going to cry.. But it's just so beautiful!");

Logging is about levels

Logbone's loggers are all about log levels (try saying that 3 times fast). The following are log levels and log methods used by Logbone. 'SILENT' is only a level, not a logging method. Loggers using a level of 'SILENT` will not output to the console.

| Level | DEBUG | INFO | WARN | ERROR | SILENT |
| -----: | :---: | :--: | :---: | :----: | ------ |
| DEBUG | YES | NO | NO | NO | NO |
| INFO | YES | YES | NO | NO | NO |
| WARN | YES | YES | YES | NO | NO |
| ERROR | YES | YES | YES | YES | NO |

Logging methods

Logbone Loggers have five logging methods that utilize native console methods: log, debug, info, warn and error.

//get a logger
var logger = Logbone.getLogger('Level-check');

logger.log('<--Log output');
logger.debug('<--Debug output');
logger.info('<--Info output');
logger.warn('<--warn output');
logger.error('<--error output');

Logging method arguments

The number of logging method arguments are limited to 10. Passing a logging method more than 10 arguments will cause the method to throw an exception. Logging methods utilize the native console, so logging objects is no problem. Should you find a secnario where you need to log more than 10 items to the console at once, consider using an object or breaking your logging up over multiple lines.

Logging format specifiers

Logbone utilizes the browser's console format specifiers. Below are some format specifiers used by most of the latest major browsers. Support for format specifiers relies on your browser. If your browser's console does not support format specifiers, you will not be able to use them.

**Note: ** These format specifiers are very widely supported.

%s - Formats the value as a string
%i or %d - Formats the value as an integer.
%f - Formats the value as a floating point value.
%o - Formats the value as an expandable DOM element. As seen in the Elements panel.
%O - Formats the value as an expandable JavaScript object.

API

Logbone.level.[level] - [log, debug, info, warn, error, silent] - String

A constants object containing Strings representing Logbone's level constants.
It is recommended but not required to use this object when setting logging levels.

logger.setLevel(Logbone.level.info) - (recommended)
logger.setLevel('INFO') - also works

Logbone.value.[value] - [log, debug, info, warn, error, silent] - number

A constants object containing numbers that represent Logbone levels.

Logbone.defaults - Object

An object containing Logbone's level and value defaults used during initialization.

Logbone.error - Object

An object containing error message constants.

Logbone.setLevel(level) - void

Sets Logbone's global logging level.

Logbone.getLevel() - String

Returns Logbone's global log level.

Logbone.levelExists(String) - boolean

Returns true if the supplied String argument is a valid logging level, else returns false.

Logbone.getLogger(name, [prefix], [level]) - Logger

name - name of the Logger (required)
prefix - prefix for the logger (optional)
level - the Logger's logging level. If none specified, global log level is used. Returns a new Logger object

Logger.getSubLogger(identifier) - Logger

identifier - name to be used for the sub-logger
Returns a new Logger instance using the logger's log level and name. The sub-logger's prefix is the parent logger's name and the sub-logger's name is the supplied identifier parameter.

Logger.log(args) - up to 10 args

Logging method. Only outputs to the console when the active log level is 'LOG'. Calls console.log with formatted arguments.

Logger.debug(args) - up to 10 args

Logging method. Only outputs to console when the active log level is 'DEBUG' or lower. Calls console.debug with formatted arguments.

Logger.info(args) - up to 10 args

Logging method. Only outputs to console when the active log level is 'INFO' or lower. Calls console.info with formatted arguments.

Logger.warn(args) - up to 10 args

Logging method. Only outputs to console when the active log level is 'WARN' or lower. Calls console.warn with formatted arguments.

Logger.error(args) - up to 10 args

Logging method. Only outputs to console when the active log level is 'ERROR' or lower. Calls console.error with formatted arguments.

Logger.getLevel() - String

Returns the active logging level for the Logger.

Logger.getLevelValue() - number

Returns the active logging value for the Logger.

Logger.setLevel(level) - void

Sets the active logging level for the Logger. Setting a logging level on a Logger will cause the Logger to use the new level argument instead of the global logging level.