1.0.3 • Published 7 years ago

hunterslogger v1.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

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

ParamTypeDescription
moduleNameStringname of the module that is consuming Logger

logger.log(message)

Log a message to the browser console

Kind: instance method of Logger

ParamTypeDescription
messageStringmessage to be logged

logger.warn(message)

Log a warning to the console

Kind: instance method of Logger

ParamType
messageString

logger.error(message)

Log an error to the console

Kind: instance method of Logger

ParamType
messageString

verifyVariableIsType(variable, type)

Verify that a given variable is of a particular type.

Kind: global function

ParamTypeDescription
variable*the variable being verified
typeStringthe 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.

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago