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

hunterslogger

v1.0.3

Published

A utility for managing console logs within a JavaScript application

Downloads

41

Readme

Build Status

logger

A utility for managing console logs within a JavaScript application. This utility allows for centralized control over the format of application logs.

Tables of contents

Installing

npm install --save hunterslogger

Usage

import Logger from 'hunterslogger';
const logger = new Logger('nameOfThisFile');

...

logger.log('your log message');
logger.warn('your warning');
logger.error('your error');

Classes

Functions

Logger

Kind: global class

new Logger(moduleName)

Conctructor

| Param | Type | Description | | --- | --- | --- | | moduleName | String | name of the module that is consuming Logger |

logger.log(message)

Log a message to the browser console

Kind: instance method of Logger

| Param | Type | Description | | --- | --- | --- | | message | String | message to be logged |

logger.warn(message)

Log a warning to the console

Kind: instance method of Logger

| Param | Type | | --- | --- | | message | String |

logger.error(message)

Log an error to the console

Kind: instance method of Logger

| Param | Type | | --- | --- | | message | String |

verifyVariableIsType(variable, type)

Verify that a given variable is of a particular type.

Kind: global function

| Param | Type | Description | | --- | --- | --- | | variable | * | the variable being verified | | type | String | the expected type of the variable |

Contributing

  1. Pull down the code into a local git repo
  2. Install the development dependencies: npm install
  3. Make your changes (be sure to have unit tests covering your changes)
  4. Run the unit tests: npm run test
  5. If all of the unit tests pass, build the source code: npm run build
  6. Submit a pull request :)

Testing

Tests are run with Jasmine: https://jasmine.github.io/index.html Tests can be run with the following command: npm run test

I wanted to maintain a build status, so I decided to use Travis CI after finding the following StackOverflow answer after some googling: https://stackoverflow.com/questions/13546097/how-do-show-my-tests-passing-failing-in-github

Since specs are written using ES2015 syntax, spec files must be transpiled using babel. I detail how I created this build step below.

When I initially attempted to run the Jasmine unit tests, I received the following error in the console:

Hunters-MacBook-Pro:logger hunterhodnett$ ./node_modules/.bin/jasmine
/Users/hunterhodnett/PersonalProjects/logger/spec/logger.spec.js:5
import Logger from '../src/logger.js';
^^^^^^
SyntaxError: Unexpected token import

This led me to the following StackOverflow question: https://stackoverflow.com/questions/39436322/node-js-syntaxerror-unexpected-token-import
...which led me to perform the following google search: https://www.google.com/search?q=jasmine+spec+babel&rlz=1C5CHFA_enUS725US725&oq=jasmine+spec+babel&aqs=chrome..69i57.5799j0j4&sourceid=chrome&ie=UTF-8
...which led me to the following gist (first result in google search): https://gist.github.com/mauvm/172878a9646095d03fd7
...which led me to create the run.js file in the /spec directory, as well as change the "test" command (within the "scripts" section of package.json) to "./node_modules/.bin/babel-node spec/run.js", which kicks off a transpile of run.js, which imports and runs Jasmine from within a node environment that supports ES2015 syntax.