js-logger
Advanced tools
Comparing version 1.5.0 to 1.6.0
{ | ||
"name": "js-logger", | ||
"version": "1.5.0", | ||
"main": "src/logger.js", | ||
@@ -5,0 +4,0 @@ "ignore": [ |
@@ -1,2 +0,9 @@ | ||
## 1.5.0 (13th October, 2017) | ||
## 1.6.0 | ||
- Released 23rd October, 2017 | ||
- Fix broken TypeScript definitions introduced in 1.5.0, fixes #85 | ||
- Add `Logger.trace()` method to TypeScript definitions, fixes #86 | ||
- Export all interfaces in TypeScript definitions | ||
## 1.5.0 | ||
- Released 13th October, 2017 | ||
- Added `Logger.trace()` (#67, @ddanila) | ||
@@ -6,6 +13,8 @@ - Fix TypeScript definitions for ILoggerOpts (#70, @timm-gs) | ||
## 1.4.1 (19th August, 2017) | ||
## 1.4.1 | ||
- Released 19th August, 2017 | ||
- Fixed `Logger.getLevel()` Typescript definition error (#57, @timaebi) | ||
## 1.4.0 (18th August, 2017) | ||
## 1.4.0 | ||
- Released 18th August, 2017 | ||
- Add `Logger.getLevel()` (#49, @BenjaminVadant) | ||
@@ -17,3 +26,4 @@ - Invoke `console.debug` if present (#34, @ajwagner777) | ||
## 1.3.0 (5th July, 2016) | ||
## 1.3.0 | ||
- Released 5th July, 2016 | ||
- Add `Logger.createDefaultHandler()`, fixes #26 | ||
@@ -23,34 +33,39 @@ - Correct typo in README, fixes #28 | ||
## 1.2.0 (10 September, 2015) | ||
## 1.2.0 | ||
- Released 10 September, 2015 | ||
- Support for custom message formatter in Logger.useDefaults() | ||
- Logger.useDefaults() now expects a hash instead of a logLevel. | ||
## 1.1.1 (14th July, 2015) | ||
## 1.1.1 | ||
- Released 14th July, 2015 | ||
- Fixed botched npm release of 1.1.0 :) | ||
## 1.1.0 (14th July, 2015) | ||
## 1.1.0 | ||
- Released 14th July, 2015 | ||
- Prevent stringification of objects (#17, @paulinthought) | ||
## 1.0.0 (18th April, 2015) | ||
## 1.0.0 | ||
- Released 18th April, 2015 | ||
- Introduce timing operations (#time and #timeEnd) | ||
- Update gulp dependencies. | ||
## 0.9.14 (4th September, 2014) | ||
## 0.9.14 | ||
- Released 4th September, 2014 | ||
- Fix for IE7 (#10, @james-west) | ||
## 0.9.12 (13th July, 2014) | ||
## 0.9.12 | ||
- Released 13th July, 2014 | ||
- Fixed `release` task to correctly push tags to origin. | ||
## 0.9.11 (11th July, 2014) | ||
## 0.9.11 | ||
- Released 11th July, 2014 | ||
- Twiddling with the build and packaging process. | ||
- Added npm test script (`npm test`). | ||
## 0.9.8 (11th July, 2014) | ||
Bugfixes: | ||
## 0.9.8 | ||
- Released 11th July, 2014 | ||
- Added missing minified file. | ||
## 0.9.7 (11th July, 2014) | ||
Bugfixes: | ||
## 0.9.7 | ||
- Released 11th July, 2014 | ||
- Bower version updated. | ||
@@ -61,10 +76,8 @@ - Whitespace issue (spaces instead of tabs). | ||
## 0.9.6 (20th May, 2014) | ||
Bugfixes: | ||
## 0.9.6 | ||
- Released 20th May, 2014 | ||
- `Logger.useDefaults()` now supports IE8+ (#4, @AdrianTP) | ||
## 0.9.5 (19th May, 2014) | ||
Bugfixes: | ||
## 0.9.5 | ||
- Released 19th May, 2014 | ||
- Support for NodeJS environment (#9, @fatso83) |
{ | ||
"name": "js-logger", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"license": "MIT", | ||
@@ -24,16 +24,19 @@ "description": "Lightweight, unobtrusive, configurable JavaScript logger", | ||
"scripts": { | ||
"test": "gulp test lint", | ||
"build": "gulp default" | ||
"lint": "jshint --exclude=src/*.min.js src/*.js test-src/*.js", | ||
"test": "npm run test:unit && npm run test:tsd", | ||
"test:unit": "node-qunit-phantomjs ./test-src/index.html", | ||
"test:tsd": "cd test-src/typescript-consumer && tsc --noEmit index", | ||
"build": "npm run build:version && npm run build:minify", | ||
"build:minify": "uglifyjs src/logger.js --mangle --compress -o src/logger.min.js", | ||
"build:version": "cross-env replace -s 'VERSION = \"[^\"]+\"' \"VERSION = \\\"$npm_package_version\\\"\" src/logger.js" | ||
}, | ||
"devDependencies": { | ||
"gulp": "~3.8.11", | ||
"gulp-util": "~2.2.14", | ||
"gulp-uglify": "~1.2.0", | ||
"gulp-replace": "~0.5.3", | ||
"gulp-rename": "~1.2.0", | ||
"gulp-qunit": "~1.5.0", | ||
"gulp-jshint": "~1.10.0", | ||
"gulp-size": "~1.2.1", | ||
"gulp-git": "~1.2.0" | ||
"cross-env": "^5.2.0", | ||
"jshint": "^2.9.6", | ||
"node-qunit-phantomjs": "^2.0.0", | ||
"replace": "^1.0.0", | ||
"rimraf": "^2.6.2", | ||
"typescript": "^3.1.3", | ||
"uglify-js": "^3.4.9" | ||
} | ||
} |
@@ -151,1 +151,4 @@ # js-Logger [![Build Status](https://travis-ci.org/jonnyreeves/js-logger.svg?branch=master)](https://travis-ci.org/jonnyreeves/js-logger) [![npm version](https://badge.fury.io/js/js-logger.svg)](http://badge.fury.io/js/js-logger) ![npm dependencies](https://david-dm.org/jonnyreeves/js-logger.png) | ||
Note that `time` and `timeEnd` methods are also provided to named Logger instances. | ||
## Usage with TypeScript | ||
TypeScript is great, you should use it. See [the typescript consumer test](blob/master/test-src/typescript-consumer/index.ts) for example usage. |
@@ -1,112 +0,4 @@ | ||
/** | ||
* @module js-logger | ||
* @description Typescript description for js-logger | ||
*/ | ||
interface ILogLevel extends Object { | ||
/** | ||
* The numerical representation of the level | ||
*/ | ||
value: number; | ||
/** | ||
* Human readable name of the log level | ||
*/ | ||
name: string; | ||
} | ||
import { GlobalLogger } from './types' | ||
interface IContext extends Object { | ||
/** | ||
* The currrent log level | ||
*/ | ||
level: ILogLevel; | ||
/** | ||
* The optional current logger name | ||
*/ | ||
name?: string; | ||
} | ||
/** | ||
* Defines custom formatter for the log message | ||
* @callback formatterCallback | ||
* @param {any[]} messages the given logger arguments | ||
* @param {IContext} context the current logger context (level and name) | ||
*/ | ||
interface ILoggerOpts extends Object { | ||
/** | ||
* The log level, default is DEBUG | ||
*/ | ||
defaultLevel?: ILogLevel; | ||
/** | ||
* Defines custom formatter for the log message | ||
* @param {formatterCallback} callback the callback which handles the formatting | ||
*/ | ||
formatter?: (messages: any[], context: IContext) => void; | ||
} | ||
/** | ||
* Defines custom handler for the log message | ||
* @callback setHandlerCallback | ||
* @param {any[]} messages the given logger arguments | ||
* @param {IContext} context the current logger context (level and name) | ||
*/ | ||
export interface ILogger { | ||
DEBUG: ILogLevel; | ||
INFO: ILogLevel; | ||
TIME: ILogLevel; | ||
WARN: ILogLevel; | ||
ERROR: ILogLevel; | ||
OFF: ILogLevel; | ||
debug(...x: any[]): void; | ||
info(...x: any[]): void; | ||
log(...x: any[]): void; | ||
warn(...x: any[]): void; | ||
error(...x: any[]): void; | ||
/** | ||
* Configure and example a Default implementation which writes to the | ||
* `window.console` (if present). The `options` hash can be used to configure | ||
* the default logLevel and provide a custom message formatter. | ||
*/ | ||
useDefaults(options?: ILoggerOpts): void; | ||
/** | ||
* Sets the global logging filter level which applies to *all* previously | ||
* registered, and future Logger instances. (note that named loggers (retrieved | ||
* via `Logger.get`) can be configured independently if required). | ||
* | ||
* @param {ILogLevel} level the level to switch to | ||
*/ | ||
setLevel(level: ILogLevel): void; | ||
/** | ||
* Gets the global logging filter level | ||
* | ||
* @return {ILogLevel} the current logging level | ||
*/ | ||
getLevel(): ILogLevel; | ||
/** | ||
* Set the global logging handler. The supplied function should | ||
* expect two arguments, the first being an arguments object with the | ||
* supplied log messages and the second being a context object which | ||
* contains a hash of stateful parameters which the logging function can consume. | ||
* @param {setHandlerCallback} callback the callback which handles the logging | ||
*/ | ||
setHandler(logHandler: (messages: any[], context: IContext) => void): void; | ||
/** | ||
* Retrieve a ContextualLogger instance. Note that named loggers automatically | ||
* inherit the global logger's level, default context and log handler. | ||
* | ||
* @param {string} name the logger name | ||
* @return {ILogger} the named logger | ||
*/ | ||
get(name: string): ILogger; | ||
time(label: string): void; | ||
timeEnd(label: string): void; | ||
enabledFor(level: ILogLevel): boolean; | ||
createDefaultHandler(options?: ILoggerOpts): (messages: any[], context: IContext) => void; | ||
} | ||
declare var Logger: ILogger; | ||
declare var Logger: GlobalLogger; | ||
export = Logger; |
@@ -13,3 +13,3 @@ /*! | ||
// For those that are at home that are keeping score. | ||
Logger.VERSION = "1.5.0"; | ||
Logger.VERSION = "1.6.0"; | ||
@@ -16,0 +16,0 @@ // Function which handles all incoming log messages. |
@@ -1,1 +0,1 @@ | ||
!function(e){"use strict";var n={};n.VERSION="1.5.0";var t,o={},r=function(e,n){return function(){return n.apply(e,arguments)}},i=function(){var e,n,t=arguments,o=t[0];for(n=1;n<t.length;n++)for(e in t[n])e in o||!t[n].hasOwnProperty(e)||(o[e]=t[n][e]);return o},l=function(e,n){return{value:e,name:n}};n.TRACE=l(1,"TRACE"),n.DEBUG=l(2,"DEBUG"),n.INFO=l(3,"INFO"),n.TIME=l(4,"TIME"),n.WARN=l(5,"WARN"),n.ERROR=l(8,"ERROR"),n.OFF=l(99,"OFF");var u=function(e){this.context=e,this.setLevel(e.filterLevel),this.log=this.info};u.prototype={setLevel:function(e){e&&"value"in e&&(this.context.filterLevel=e)},getLevel:function(){return this.context.filterLevel},enabledFor:function(e){var n=this.context.filterLevel;return e.value>=n.value},trace:function(){this.invoke(n.TRACE,arguments)},debug:function(){this.invoke(n.DEBUG,arguments)},info:function(){this.invoke(n.INFO,arguments)},warn:function(){this.invoke(n.WARN,arguments)},error:function(){this.invoke(n.ERROR,arguments)},time:function(e){"string"==typeof e&&e.length>0&&this.invoke(n.TIME,[e,"start"])},timeEnd:function(e){"string"==typeof e&&e.length>0&&this.invoke(n.TIME,[e,"end"])},invoke:function(e,n){t&&this.enabledFor(e)&&t(n,i({level:e},this.context))}};var a=new u({filterLevel:n.OFF});!function(){var e=n;e.enabledFor=r(a,a.enabledFor),e.trace=r(a,a.trace),e.debug=r(a,a.debug),e.time=r(a,a.time),e.timeEnd=r(a,a.timeEnd),e.info=r(a,a.info),e.warn=r(a,a.warn),e.error=r(a,a.error),e.log=e.info}(),n.setHandler=function(e){t=e},n.setLevel=function(e){a.setLevel(e);for(var n in o)o.hasOwnProperty(n)&&o[n].setLevel(e)},n.getLevel=function(){return a.getLevel()},n.get=function(e){return o[e]||(o[e]=new u(i({name:e},a.context)))},n.createDefaultHandler=function(e){e=e||{},e.formatter=e.formatter||function(e,n){n.name&&e.unshift("["+n.name+"]")};var t={},o=function(e,n){Function.prototype.apply.call(e,console,n)};return"undefined"==typeof console?function(){}:function(r,i){r=Array.prototype.slice.call(r);var l,u=console.log;i.level===n.TIME?(l=(i.name?"["+i.name+"] ":"")+r[0],"start"===r[1]?console.time?console.time(l):t[l]=(new Date).getTime():console.timeEnd?console.timeEnd(l):o(u,[l+": "+((new Date).getTime()-t[l])+"ms"])):(i.level===n.WARN&&console.warn?u=console.warn:i.level===n.ERROR&&console.error?u=console.error:i.level===n.INFO&&console.info?u=console.info:i.level===n.DEBUG&&console.debug?u=console.debug:i.level===n.TRACE&&console.trace&&(u=console.trace),e.formatter(r,i),o(u,r))}},n.useDefaults=function(e){n.setLevel(e&&e.defaultLevel||n.DEBUG),n.setHandler(n.createDefaultHandler(e))},"function"==typeof define&&define.amd?define(n):"undefined"!=typeof module&&module.exports?module.exports=n:(n._prevLogger=e.Logger,n.noConflict=function(){return e.Logger=n._prevLogger,n},e.Logger=n)}(this); | ||
!function(e){"use strict";var t,c={};c.VERSION="1.6.0";var o={},n=function(e,n){return function(){return n.apply(e,arguments)}},r=function(){var e,n,t=arguments,o=t[0];for(n=1;n<t.length;n++)for(e in t[n])e in o||!t[n].hasOwnProperty(e)||(o[e]=t[n][e]);return o},i=function(e,n){return{value:e,name:n}};c.TRACE=i(1,"TRACE"),c.DEBUG=i(2,"DEBUG"),c.INFO=i(3,"INFO"),c.TIME=i(4,"TIME"),c.WARN=i(5,"WARN"),c.ERROR=i(8,"ERROR"),c.OFF=i(99,"OFF");var l=function(e){this.context=e,this.setLevel(e.filterLevel),this.log=this.info};l.prototype={setLevel:function(e){e&&"value"in e&&(this.context.filterLevel=e)},getLevel:function(){return this.context.filterLevel},enabledFor:function(e){var n=this.context.filterLevel;return e.value>=n.value},trace:function(){this.invoke(c.TRACE,arguments)},debug:function(){this.invoke(c.DEBUG,arguments)},info:function(){this.invoke(c.INFO,arguments)},warn:function(){this.invoke(c.WARN,arguments)},error:function(){this.invoke(c.ERROR,arguments)},time:function(e){"string"==typeof e&&0<e.length&&this.invoke(c.TIME,[e,"start"])},timeEnd:function(e){"string"==typeof e&&0<e.length&&this.invoke(c.TIME,[e,"end"])},invoke:function(e,n){t&&this.enabledFor(e)&&t(n,r({level:e},this.context))}};var f,u=new l({filterLevel:c.OFF});(f=c).enabledFor=n(u,u.enabledFor),f.trace=n(u,u.trace),f.debug=n(u,u.debug),f.time=n(u,u.time),f.timeEnd=n(u,u.timeEnd),f.info=n(u,u.info),f.warn=n(u,u.warn),f.error=n(u,u.error),f.log=f.info,c.setHandler=function(e){t=e},c.setLevel=function(e){for(var n in u.setLevel(e),o)o.hasOwnProperty(n)&&o[n].setLevel(e)},c.getLevel=function(){return u.getLevel()},c.get=function(e){return o[e]||(o[e]=new l(r({name:e},u.context)))},c.createDefaultHandler=function(r){(r=r||{}).formatter=r.formatter||function(e,n){n.name&&e.unshift("["+n.name+"]")};var i={},l=function(e,n){Function.prototype.apply.call(e,console,n)};return"undefined"==typeof console?function(){}:function(e,n){e=Array.prototype.slice.call(e);var t,o=console.log;n.level===c.TIME?(t=(n.name?"["+n.name+"] ":"")+e[0],"start"===e[1]?console.time?console.time(t):i[t]=(new Date).getTime():console.timeEnd?console.timeEnd(t):l(o,[t+": "+((new Date).getTime()-i[t])+"ms"])):(n.level===c.WARN&&console.warn?o=console.warn:n.level===c.ERROR&&console.error?o=console.error:n.level===c.INFO&&console.info?o=console.info:n.level===c.DEBUG&&console.debug?o=console.debug:n.level===c.TRACE&&console.trace&&(o=console.trace),r.formatter(e,n),l(o,e))}},c.useDefaults=function(e){c.setLevel(e&&e.defaultLevel||c.DEBUG),c.setHandler(c.createDefaultHandler(e))},"function"==typeof define&&define.amd?define(c):"undefined"!=typeof module&&module.exports?module.exports=c:(c._prevLogger=e.Logger,c.noConflict=function(){return e.Logger=c._prevLogger,c},e.Logger=c)}(this); |
Sorry, the diff of this file is not supported yet
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
350230
7
21
154
2
9004