From 1a22f15f0723e84d3ca83266e179183dfcd49e91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Sospedra?= Date: Sun, 27 Dec 2015 18:15:45 +0100 Subject: [PATCH] feat: Add tests for levels fix #5 --- .coveralls.yml | 1 + CHANGELOG.md | 8 ++++++ README.md | 5 +++- dist/logatim.amd.js | 1 - dist/logatim.amd.min.js | 2 +- dist/logatim.commonjs2.js | 1 - dist/logatim.commonjs2.min.js | 2 +- dist/logatim.umd.js | 1 - dist/logatim.umd.min.js | 2 +- dist/logatim.var.js | 1 - dist/logatim.var.min.js | 2 +- index.js | 2 +- lib/constants.js | 4 +-- lib/levels.js | 17 +++++++------ lib/logatim.js | 10 +++++--- lib/logs.js | 4 +-- package.json | 48 ++++++++++++++++++++++++++--------- test/test-levels.js | 30 ++++++++++++++++++++++ test/test-styles.js | 0 webpack.config.js | 4 +-- 20 files changed, 106 insertions(+), 39 deletions(-) create mode 100644 .coveralls.yml create mode 100644 CHANGELOG.md delete mode 100644 dist/logatim.amd.js delete mode 100644 dist/logatim.commonjs2.js delete mode 100644 dist/logatim.umd.js delete mode 100644 dist/logatim.var.js delete mode 100644 test/test-styles.js diff --git a/.coveralls.yml b/.coveralls.yml new file mode 100644 index 0000000..74b932f --- /dev/null +++ b/.coveralls.yml @@ -0,0 +1 @@ +repo_token: XmHs8an1FvzAdfxAf81kEPQDFnpJ4j4mw \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..4cf4a0a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,8 @@ +2015-12-27 +========== + + * feat: Add versions + fix [#4](https://github.com/edravis/logatim/issues/4) + * feat: Add semantic versioning + [#4](https://github.com/edravis/logatim/issues/4) + * Release version 1.0.0. The game starts now! diff --git a/README.md b/README.md index 74418fd..6e71a49 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,10 @@ # [Logatim](http://edravis.github.io/logatim/) -[![Build Status](https://travis-ci.org/h5bp/html5-boilerplate.svg)](https://travis-ci.org/h5bp/html5-boilerplate) +[![Build Status](https://travis-ci.org/edravis/logatim.svg?branch=master)](https://travis-ci.org/edravis/logatim) [![devDependency Status](https://david-dm.org/edravis/logatim/dev-status.svg)](https://david-dm.org/edravis/logatim#info=devDependencies) +[![Coverage Status](https://coveralls.io/repos/edravis/logatim/badge.svg?branch=master&service=github)](https://coveralls.io/github/edravis/logatim?branch=master) +[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) +[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/) #### Logatim is an isomorphic logger which implements log levels and ANSI styles. diff --git a/dist/logatim.amd.js b/dist/logatim.amd.js deleted file mode 100644 index 77ddbdb..0000000 --- a/dist/logatim.amd.js +++ /dev/null @@ -1 +0,0 @@ -define("logatim",[],function(){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return e[o].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";e.exports=n(4)("")},function(e,t){"use strict";e.exports={DEFAULT_LEVEL:"WARN",EOL:"",LOG_METHODS:["trace","debug","info","warn","error"],STORAGE_KEY:"logatimLevel",LEVELS:{TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5}}},function(e,t,n){(function(e){"use strict";function t(){var e={modifiers:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},colors:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39]},bgColors:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49]}};return e.colors.grey=e.colors.gray,Object.keys(e).forEach(function(t){var n=e[t];Object.keys(n).forEach(function(t){var o=n[t];e[t]=n[t]={open:"["+o[0]+"m",close:"["+o[1]+"m"}}),Object.defineProperty(e,t,{value:n,enumerable:!1})}),e}Object.defineProperty(e,"exports",{enumerable:!0,get:t})}).call(t,n(6)(e))},function(e,t,n){"use strict";var o=n(1),r=e.exports={};r.setLevel=function(e){if("string"==typeof e&&void 0!==r[e.toUpperCase()]&&(e=o.LEVELS[e.toUpperCase()]),"number"==typeof e&&e>=0&&e<=r.SILENT)return r.persistLevel(e),e;throw"logatim.setLevel() called with invalid level: "+e},r.persistLevel=function(e){var t=(o.LOG_METHODS[e]||"silent").toUpperCase(),n=o.STORAGE_KEY;GLOBAL[n]=t;try{return void(window.localStorage[n]=t)}catch(r){}try{window.document.cookie=encodeURIComponent(n)+"="+t+";"}catch(r){}},r.getPersistedLevel=function(){var e=void 0,t=o.STORAGE_KEY;try{e=window.localStorage[t]}catch(n){}if("undefined"==typeof e)try{var r=window.document.cookie,i=r.indexOf(encodeURIComponent(t)+"=");i&&(e=/^([^;]+)/.exec(r.slice(i))[1])}catch(n){}return void 0===o.LEVELS[e]&&(e=void 0),e=GLOBAL[t]}},function(e,t,n){"use strict";var o=n(2),r=n(3),i=n(5),c=3,u=e.exports=function(e){var t=function(t){return u(e+t)};return t.getLevel=function(){return c},t.setLevel=function(e){return c=e},Object.keys(o).forEach(function(n){Object.defineProperty(t,n,{get:function(){return u(""+e+o[n].open)}})}),t.setLevel(r.getPersistedLevel()||c),i.updateLogMethods(t,u,e,c),t}},function(e,t,n){"use strict";var o=n(1),r=e.exports={},i=function(e){var t=Array.prototype.slice.call(arguments,1),n=t.concat(o.EOL).join("");console[e](n)};r.updateLogMethods=function(e,t,n,r){o.LOG_METHODS.forEach(function(t,o){r>=o?e[t]=i.bind(null,t,n):e[t]=function(){}})}},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children=[],e.webpackPolyfill=1),e}}])}); \ No newline at end of file diff --git a/dist/logatim.amd.min.js b/dist/logatim.amd.min.js index 77ddbdb..29518ac 100644 --- a/dist/logatim.amd.min.js +++ b/dist/logatim.amd.min.js @@ -1 +1 @@ -define("logatim",[],function(){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return e[o].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";e.exports=n(4)("")},function(e,t){"use strict";e.exports={DEFAULT_LEVEL:"WARN",EOL:"",LOG_METHODS:["trace","debug","info","warn","error"],STORAGE_KEY:"logatimLevel",LEVELS:{TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5}}},function(e,t,n){(function(e){"use strict";function t(){var e={modifiers:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},colors:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39]},bgColors:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49]}};return e.colors.grey=e.colors.gray,Object.keys(e).forEach(function(t){var n=e[t];Object.keys(n).forEach(function(t){var o=n[t];e[t]=n[t]={open:"["+o[0]+"m",close:"["+o[1]+"m"}}),Object.defineProperty(e,t,{value:n,enumerable:!1})}),e}Object.defineProperty(e,"exports",{enumerable:!0,get:t})}).call(t,n(6)(e))},function(e,t,n){"use strict";var o=n(1),r=e.exports={};r.setLevel=function(e){if("string"==typeof e&&void 0!==r[e.toUpperCase()]&&(e=o.LEVELS[e.toUpperCase()]),"number"==typeof e&&e>=0&&e<=r.SILENT)return r.persistLevel(e),e;throw"logatim.setLevel() called with invalid level: "+e},r.persistLevel=function(e){var t=(o.LOG_METHODS[e]||"silent").toUpperCase(),n=o.STORAGE_KEY;GLOBAL[n]=t;try{return void(window.localStorage[n]=t)}catch(r){}try{window.document.cookie=encodeURIComponent(n)+"="+t+";"}catch(r){}},r.getPersistedLevel=function(){var e=void 0,t=o.STORAGE_KEY;try{e=window.localStorage[t]}catch(n){}if("undefined"==typeof e)try{var r=window.document.cookie,i=r.indexOf(encodeURIComponent(t)+"=");i&&(e=/^([^;]+)/.exec(r.slice(i))[1])}catch(n){}return void 0===o.LEVELS[e]&&(e=void 0),e=GLOBAL[t]}},function(e,t,n){"use strict";var o=n(2),r=n(3),i=n(5),c=3,u=e.exports=function(e){var t=function(t){return u(e+t)};return t.getLevel=function(){return c},t.setLevel=function(e){return c=e},Object.keys(o).forEach(function(n){Object.defineProperty(t,n,{get:function(){return u(""+e+o[n].open)}})}),t.setLevel(r.getPersistedLevel()||c),i.updateLogMethods(t,u,e,c),t}},function(e,t,n){"use strict";var o=n(1),r=e.exports={},i=function(e){var t=Array.prototype.slice.call(arguments,1),n=t.concat(o.EOL).join("");console[e](n)};r.updateLogMethods=function(e,t,n,r){o.LOG_METHODS.forEach(function(t,o){r>=o?e[t]=i.bind(null,t,n):e[t]=function(){}})}},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children=[],e.webpackPolyfill=1),e}}])}); \ No newline at end of file +define("logatim",[],function(){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return e[o].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";e.exports=n(4)("")},function(e,t){"use strict";e.exports={DEFAULT_LEVEL:"WARN",EOL:"",LOG_METHODS:["trace","debug","info","warn","error"],STORAGE_KEY:"logatimLevel",LEVELS:{TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5}}},function(e,t,n){(function(e){"use strict";function t(){var e={modifiers:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},colors:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39]},bgColors:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49]}};return e.colors.grey=e.colors.gray,Object.keys(e).forEach(function(t){var n=e[t];Object.keys(n).forEach(function(t){var o=n[t];e[t]=n[t]={open:"["+o[0]+"m",close:"["+o[1]+"m"}}),Object.defineProperty(e,t,{value:n,enumerable:!1})}),e}Object.defineProperty(e,"exports",{enumerable:!0,get:t})}).call(t,n(6)(e))},function(e,t,n){"use strict";var o=n(1),r=e.exports={};r.getLevel=function(e){return Object.keys(o.LEVELS)[e]},r.setLevel=function(e){if("string"==typeof e&&void 0!==o.LEVELS[e.toUpperCase()]&&(e=o.LEVELS[e.toUpperCase()]),"number"==typeof e&&e>=0&&e<=o.LEVELS.SILENT)return r.persistLevel(e),e;throw new Error("logatim.setLevel() called with invalid level: "+e)},r.persistLevel=function(e){var t=(o.LOG_METHODS[e]||"silent").toUpperCase(),n=o.STORAGE_KEY;GLOBAL[n]=t;try{return void(window.localStorage[n]=t)}catch(r){}try{window.document.cookie=encodeURIComponent(n)+"="+t+";"}catch(r){}},r.getPersistedLevel=function(){var e=void 0,t=o.STORAGE_KEY;try{e=window.localStorage[t]}catch(n){}if("undefined"==typeof e)try{var r=window.document.cookie,i=r.indexOf(encodeURIComponent(t)+"=");i&&(e=/^([^;]+)/.exec(r.slice(i))[1])}catch(n){}return void 0===o.LEVELS[e]&&(e=void 0),e=GLOBAL[t]}},function(e,t,n){"use strict";var o=n(2),r=n(3),i=n(5),c=3,u=e.exports=function(e){var t=function(t){return u(e+t)};return t.getLevel=function(){return r.getLevel(c)},t.setLevel=function(n){c=r.setLevel(n),i.updateLogMethods(t,e,c)},Object.keys(o).forEach(function(n){Object.defineProperty(t,n,{get:function(){return u(""+e+o[n].open)}})}),t.setLevel(r.getPersistedLevel()||c),i.updateLogMethods(t,e,c),t}},function(e,t,n){"use strict";var o=n(1),r=e.exports={},i=function(e){var t=Array.prototype.slice.call(arguments,1),n=t.concat(o.EOL).join("");console[e](n)};r.updateLogMethods=function(e,t,n){o.LOG_METHODS.forEach(function(o,r){r>=n?e[o]=i.bind(null,o,t):e[o]=function(){}})}},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children=[],e.webpackPolyfill=1),e}}])}); \ No newline at end of file diff --git a/dist/logatim.commonjs2.js b/dist/logatim.commonjs2.js deleted file mode 100644 index a46824b..0000000 --- a/dist/logatim.commonjs2.js +++ /dev/null @@ -1 +0,0 @@ -module.exports=function(e){function t(n){if(o[n])return o[n].exports;var r=o[n]={exports:{},id:n,loaded:!1};return e[n].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var o={};return t.m=e,t.c=o,t.p="",t(0)}([function(e,t,o){"use strict";e.exports=o(4)("")},function(e,t){"use strict";e.exports={DEFAULT_LEVEL:"WARN",EOL:"",LOG_METHODS:["trace","debug","info","warn","error"],STORAGE_KEY:"logatimLevel",LEVELS:{TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5}}},function(e,t,o){(function(e){"use strict";function t(){var e={modifiers:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},colors:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39]},bgColors:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49]}};return e.colors.grey=e.colors.gray,Object.keys(e).forEach(function(t){var o=e[t];Object.keys(o).forEach(function(t){var n=o[t];e[t]=o[t]={open:"["+n[0]+"m",close:"["+n[1]+"m"}}),Object.defineProperty(e,t,{value:o,enumerable:!1})}),e}Object.defineProperty(e,"exports",{enumerable:!0,get:t})}).call(t,o(6)(e))},function(e,t,o){"use strict";var n=o(1),r=e.exports={};r.setLevel=function(e){if("string"==typeof e&&void 0!==r[e.toUpperCase()]&&(e=n.LEVELS[e.toUpperCase()]),"number"==typeof e&&e>=0&&e<=r.SILENT)return r.persistLevel(e),e;throw"logatim.setLevel() called with invalid level: "+e},r.persistLevel=function(e){var t=(n.LOG_METHODS[e]||"silent").toUpperCase(),o=n.STORAGE_KEY;GLOBAL[o]=t;try{return void(window.localStorage[o]=t)}catch(r){}try{window.document.cookie=encodeURIComponent(o)+"="+t+";"}catch(r){}},r.getPersistedLevel=function(){var e=void 0,t=n.STORAGE_KEY;try{e=window.localStorage[t]}catch(o){}if("undefined"==typeof e)try{var r=window.document.cookie,c=r.indexOf(encodeURIComponent(t)+"=");c&&(e=/^([^;]+)/.exec(r.slice(c))[1])}catch(o){}return void 0===n.LEVELS[e]&&(e=void 0),e=GLOBAL[t]}},function(e,t,o){"use strict";var n=o(2),r=o(3),c=o(5),i=3,u=e.exports=function(e){var t=function(t){return u(e+t)};return t.getLevel=function(){return i},t.setLevel=function(e){return i=e},Object.keys(n).forEach(function(o){Object.defineProperty(t,o,{get:function(){return u(""+e+n[o].open)}})}),t.setLevel(r.getPersistedLevel()||i),c.updateLogMethods(t,u,e,i),t}},function(e,t,o){"use strict";var n=o(1),r=e.exports={},c=function(e){var t=Array.prototype.slice.call(arguments,1),o=t.concat(n.EOL).join("");console[e](o)};r.updateLogMethods=function(e,t,o,r){n.LOG_METHODS.forEach(function(t,n){r>=n?e[t]=c.bind(null,t,o):e[t]=function(){}})}},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children=[],e.webpackPolyfill=1),e}}]); \ No newline at end of file diff --git a/dist/logatim.commonjs2.min.js b/dist/logatim.commonjs2.min.js index a46824b..53e145f 100644 --- a/dist/logatim.commonjs2.min.js +++ b/dist/logatim.commonjs2.min.js @@ -1 +1 @@ -module.exports=function(e){function t(n){if(o[n])return o[n].exports;var r=o[n]={exports:{},id:n,loaded:!1};return e[n].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var o={};return t.m=e,t.c=o,t.p="",t(0)}([function(e,t,o){"use strict";e.exports=o(4)("")},function(e,t){"use strict";e.exports={DEFAULT_LEVEL:"WARN",EOL:"",LOG_METHODS:["trace","debug","info","warn","error"],STORAGE_KEY:"logatimLevel",LEVELS:{TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5}}},function(e,t,o){(function(e){"use strict";function t(){var e={modifiers:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},colors:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39]},bgColors:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49]}};return e.colors.grey=e.colors.gray,Object.keys(e).forEach(function(t){var o=e[t];Object.keys(o).forEach(function(t){var n=o[t];e[t]=o[t]={open:"["+n[0]+"m",close:"["+n[1]+"m"}}),Object.defineProperty(e,t,{value:o,enumerable:!1})}),e}Object.defineProperty(e,"exports",{enumerable:!0,get:t})}).call(t,o(6)(e))},function(e,t,o){"use strict";var n=o(1),r=e.exports={};r.setLevel=function(e){if("string"==typeof e&&void 0!==r[e.toUpperCase()]&&(e=n.LEVELS[e.toUpperCase()]),"number"==typeof e&&e>=0&&e<=r.SILENT)return r.persistLevel(e),e;throw"logatim.setLevel() called with invalid level: "+e},r.persistLevel=function(e){var t=(n.LOG_METHODS[e]||"silent").toUpperCase(),o=n.STORAGE_KEY;GLOBAL[o]=t;try{return void(window.localStorage[o]=t)}catch(r){}try{window.document.cookie=encodeURIComponent(o)+"="+t+";"}catch(r){}},r.getPersistedLevel=function(){var e=void 0,t=n.STORAGE_KEY;try{e=window.localStorage[t]}catch(o){}if("undefined"==typeof e)try{var r=window.document.cookie,c=r.indexOf(encodeURIComponent(t)+"=");c&&(e=/^([^;]+)/.exec(r.slice(c))[1])}catch(o){}return void 0===n.LEVELS[e]&&(e=void 0),e=GLOBAL[t]}},function(e,t,o){"use strict";var n=o(2),r=o(3),c=o(5),i=3,u=e.exports=function(e){var t=function(t){return u(e+t)};return t.getLevel=function(){return i},t.setLevel=function(e){return i=e},Object.keys(n).forEach(function(o){Object.defineProperty(t,o,{get:function(){return u(""+e+n[o].open)}})}),t.setLevel(r.getPersistedLevel()||i),c.updateLogMethods(t,u,e,i),t}},function(e,t,o){"use strict";var n=o(1),r=e.exports={},c=function(e){var t=Array.prototype.slice.call(arguments,1),o=t.concat(n.EOL).join("");console[e](o)};r.updateLogMethods=function(e,t,o,r){n.LOG_METHODS.forEach(function(t,n){r>=n?e[t]=c.bind(null,t,o):e[t]=function(){}})}},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children=[],e.webpackPolyfill=1),e}}]); \ No newline at end of file +module.exports=function(e){function t(n){if(o[n])return o[n].exports;var r=o[n]={exports:{},id:n,loaded:!1};return e[n].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var o={};return t.m=e,t.c=o,t.p="",t(0)}([function(e,t,o){"use strict";e.exports=o(4)("")},function(e,t){"use strict";e.exports={DEFAULT_LEVEL:"WARN",EOL:"",LOG_METHODS:["trace","debug","info","warn","error"],STORAGE_KEY:"logatimLevel",LEVELS:{TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5}}},function(e,t,o){(function(e){"use strict";function t(){var e={modifiers:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},colors:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39]},bgColors:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49]}};return e.colors.grey=e.colors.gray,Object.keys(e).forEach(function(t){var o=e[t];Object.keys(o).forEach(function(t){var n=o[t];e[t]=o[t]={open:"["+n[0]+"m",close:"["+n[1]+"m"}}),Object.defineProperty(e,t,{value:o,enumerable:!1})}),e}Object.defineProperty(e,"exports",{enumerable:!0,get:t})}).call(t,o(6)(e))},function(e,t,o){"use strict";var n=o(1),r=e.exports={};r.getLevel=function(e){return Object.keys(n.LEVELS)[e]},r.setLevel=function(e){if("string"==typeof e&&void 0!==n.LEVELS[e.toUpperCase()]&&(e=n.LEVELS[e.toUpperCase()]),"number"==typeof e&&e>=0&&e<=n.LEVELS.SILENT)return r.persistLevel(e),e;throw new Error("logatim.setLevel() called with invalid level: "+e)},r.persistLevel=function(e){var t=(n.LOG_METHODS[e]||"silent").toUpperCase(),o=n.STORAGE_KEY;GLOBAL[o]=t;try{return void(window.localStorage[o]=t)}catch(r){}try{window.document.cookie=encodeURIComponent(o)+"="+t+";"}catch(r){}},r.getPersistedLevel=function(){var e=void 0,t=n.STORAGE_KEY;try{e=window.localStorage[t]}catch(o){}if("undefined"==typeof e)try{var r=window.document.cookie,c=r.indexOf(encodeURIComponent(t)+"=");c&&(e=/^([^;]+)/.exec(r.slice(c))[1])}catch(o){}return void 0===n.LEVELS[e]&&(e=void 0),e=GLOBAL[t]}},function(e,t,o){"use strict";var n=o(2),r=o(3),c=o(5),i=3,u=e.exports=function(e){var t=function(t){return u(e+t)};return t.getLevel=function(){return r.getLevel(i)},t.setLevel=function(o){i=r.setLevel(o),c.updateLogMethods(t,e,i)},Object.keys(n).forEach(function(o){Object.defineProperty(t,o,{get:function(){return u(""+e+n[o].open)}})}),t.setLevel(r.getPersistedLevel()||i),c.updateLogMethods(t,e,i),t}},function(e,t,o){"use strict";var n=o(1),r=e.exports={},c=function(e){var t=Array.prototype.slice.call(arguments,1),o=t.concat(n.EOL).join("");console[e](o)};r.updateLogMethods=function(e,t,o){n.LOG_METHODS.forEach(function(n,r){r>=o?e[n]=c.bind(null,n,t):e[n]=function(){}})}},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children=[],e.webpackPolyfill=1),e}}]); \ No newline at end of file diff --git a/dist/logatim.umd.js b/dist/logatim.umd.js deleted file mode 100644 index 24cc5f1..0000000 --- a/dist/logatim.umd.js +++ /dev/null @@ -1 +0,0 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.logatim=t():e.logatim=t()}(this,function(){return function(e){function t(n){if(o[n])return o[n].exports;var r=o[n]={exports:{},id:n,loaded:!1};return e[n].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var o={};return t.m=e,t.c=o,t.p="",t(0)}([function(e,t,o){"use strict";e.exports=o(4)("")},function(e,t){"use strict";e.exports={DEFAULT_LEVEL:"WARN",EOL:"",LOG_METHODS:["trace","debug","info","warn","error"],STORAGE_KEY:"logatimLevel",LEVELS:{TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5}}},function(e,t,o){(function(e){"use strict";function t(){var e={modifiers:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},colors:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39]},bgColors:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49]}};return e.colors.grey=e.colors.gray,Object.keys(e).forEach(function(t){var o=e[t];Object.keys(o).forEach(function(t){var n=o[t];e[t]=o[t]={open:"["+n[0]+"m",close:"["+n[1]+"m"}}),Object.defineProperty(e,t,{value:o,enumerable:!1})}),e}Object.defineProperty(e,"exports",{enumerable:!0,get:t})}).call(t,o(6)(e))},function(e,t,o){"use strict";var n=o(1),r=e.exports={};r.setLevel=function(e){if("string"==typeof e&&void 0!==r[e.toUpperCase()]&&(e=n.LEVELS[e.toUpperCase()]),"number"==typeof e&&e>=0&&e<=r.SILENT)return r.persistLevel(e),e;throw"logatim.setLevel() called with invalid level: "+e},r.persistLevel=function(e){var t=(n.LOG_METHODS[e]||"silent").toUpperCase(),o=n.STORAGE_KEY;GLOBAL[o]=t;try{return void(window.localStorage[o]=t)}catch(r){}try{window.document.cookie=encodeURIComponent(o)+"="+t+";"}catch(r){}},r.getPersistedLevel=function(){var e=void 0,t=n.STORAGE_KEY;try{e=window.localStorage[t]}catch(o){}if("undefined"==typeof e)try{var r=window.document.cookie,i=r.indexOf(encodeURIComponent(t)+"=");i&&(e=/^([^;]+)/.exec(r.slice(i))[1])}catch(o){}return void 0===n.LEVELS[e]&&(e=void 0),e=GLOBAL[t]}},function(e,t,o){"use strict";var n=o(2),r=o(3),i=o(5),c=3,u=e.exports=function(e){var t=function(t){return u(e+t)};return t.getLevel=function(){return c},t.setLevel=function(e){return c=e},Object.keys(n).forEach(function(o){Object.defineProperty(t,o,{get:function(){return u(""+e+n[o].open)}})}),t.setLevel(r.getPersistedLevel()||c),i.updateLogMethods(t,u,e,c),t}},function(e,t,o){"use strict";var n=o(1),r=e.exports={},i=function(e){var t=Array.prototype.slice.call(arguments,1),o=t.concat(n.EOL).join("");console[e](o)};r.updateLogMethods=function(e,t,o,r){n.LOG_METHODS.forEach(function(t,n){r>=n?e[t]=i.bind(null,t,o):e[t]=function(){}})}},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children=[],e.webpackPolyfill=1),e}}])}); \ No newline at end of file diff --git a/dist/logatim.umd.min.js b/dist/logatim.umd.min.js index 24cc5f1..e306270 100644 --- a/dist/logatim.umd.min.js +++ b/dist/logatim.umd.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.logatim=t():e.logatim=t()}(this,function(){return function(e){function t(n){if(o[n])return o[n].exports;var r=o[n]={exports:{},id:n,loaded:!1};return e[n].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var o={};return t.m=e,t.c=o,t.p="",t(0)}([function(e,t,o){"use strict";e.exports=o(4)("")},function(e,t){"use strict";e.exports={DEFAULT_LEVEL:"WARN",EOL:"",LOG_METHODS:["trace","debug","info","warn","error"],STORAGE_KEY:"logatimLevel",LEVELS:{TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5}}},function(e,t,o){(function(e){"use strict";function t(){var e={modifiers:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},colors:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39]},bgColors:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49]}};return e.colors.grey=e.colors.gray,Object.keys(e).forEach(function(t){var o=e[t];Object.keys(o).forEach(function(t){var n=o[t];e[t]=o[t]={open:"["+n[0]+"m",close:"["+n[1]+"m"}}),Object.defineProperty(e,t,{value:o,enumerable:!1})}),e}Object.defineProperty(e,"exports",{enumerable:!0,get:t})}).call(t,o(6)(e))},function(e,t,o){"use strict";var n=o(1),r=e.exports={};r.setLevel=function(e){if("string"==typeof e&&void 0!==r[e.toUpperCase()]&&(e=n.LEVELS[e.toUpperCase()]),"number"==typeof e&&e>=0&&e<=r.SILENT)return r.persistLevel(e),e;throw"logatim.setLevel() called with invalid level: "+e},r.persistLevel=function(e){var t=(n.LOG_METHODS[e]||"silent").toUpperCase(),o=n.STORAGE_KEY;GLOBAL[o]=t;try{return void(window.localStorage[o]=t)}catch(r){}try{window.document.cookie=encodeURIComponent(o)+"="+t+";"}catch(r){}},r.getPersistedLevel=function(){var e=void 0,t=n.STORAGE_KEY;try{e=window.localStorage[t]}catch(o){}if("undefined"==typeof e)try{var r=window.document.cookie,i=r.indexOf(encodeURIComponent(t)+"=");i&&(e=/^([^;]+)/.exec(r.slice(i))[1])}catch(o){}return void 0===n.LEVELS[e]&&(e=void 0),e=GLOBAL[t]}},function(e,t,o){"use strict";var n=o(2),r=o(3),i=o(5),c=3,u=e.exports=function(e){var t=function(t){return u(e+t)};return t.getLevel=function(){return c},t.setLevel=function(e){return c=e},Object.keys(n).forEach(function(o){Object.defineProperty(t,o,{get:function(){return u(""+e+n[o].open)}})}),t.setLevel(r.getPersistedLevel()||c),i.updateLogMethods(t,u,e,c),t}},function(e,t,o){"use strict";var n=o(1),r=e.exports={},i=function(e){var t=Array.prototype.slice.call(arguments,1),o=t.concat(n.EOL).join("");console[e](o)};r.updateLogMethods=function(e,t,o,r){n.LOG_METHODS.forEach(function(t,n){r>=n?e[t]=i.bind(null,t,o):e[t]=function(){}})}},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children=[],e.webpackPolyfill=1),e}}])}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.logatim=t():e.logatim=t()}(this,function(){return function(e){function t(n){if(o[n])return o[n].exports;var r=o[n]={exports:{},id:n,loaded:!1};return e[n].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var o={};return t.m=e,t.c=o,t.p="",t(0)}([function(e,t,o){"use strict";e.exports=o(4)("")},function(e,t){"use strict";e.exports={DEFAULT_LEVEL:"WARN",EOL:"",LOG_METHODS:["trace","debug","info","warn","error"],STORAGE_KEY:"logatimLevel",LEVELS:{TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5}}},function(e,t,o){(function(e){"use strict";function t(){var e={modifiers:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},colors:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39]},bgColors:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49]}};return e.colors.grey=e.colors.gray,Object.keys(e).forEach(function(t){var o=e[t];Object.keys(o).forEach(function(t){var n=o[t];e[t]=o[t]={open:"["+n[0]+"m",close:"["+n[1]+"m"}}),Object.defineProperty(e,t,{value:o,enumerable:!1})}),e}Object.defineProperty(e,"exports",{enumerable:!0,get:t})}).call(t,o(6)(e))},function(e,t,o){"use strict";var n=o(1),r=e.exports={};r.getLevel=function(e){return Object.keys(n.LEVELS)[e]},r.setLevel=function(e){if("string"==typeof e&&void 0!==n.LEVELS[e.toUpperCase()]&&(e=n.LEVELS[e.toUpperCase()]),"number"==typeof e&&e>=0&&e<=n.LEVELS.SILENT)return r.persistLevel(e),e;throw new Error("logatim.setLevel() called with invalid level: "+e)},r.persistLevel=function(e){var t=(n.LOG_METHODS[e]||"silent").toUpperCase(),o=n.STORAGE_KEY;GLOBAL[o]=t;try{return void(window.localStorage[o]=t)}catch(r){}try{window.document.cookie=encodeURIComponent(o)+"="+t+";"}catch(r){}},r.getPersistedLevel=function(){var e=void 0,t=n.STORAGE_KEY;try{e=window.localStorage[t]}catch(o){}if("undefined"==typeof e)try{var r=window.document.cookie,i=r.indexOf(encodeURIComponent(t)+"=");i&&(e=/^([^;]+)/.exec(r.slice(i))[1])}catch(o){}return void 0===n.LEVELS[e]&&(e=void 0),e=GLOBAL[t]}},function(e,t,o){"use strict";var n=o(2),r=o(3),i=o(5),c=3,u=e.exports=function(e){var t=function(t){return u(e+t)};return t.getLevel=function(){return r.getLevel(c)},t.setLevel=function(o){c=r.setLevel(o),i.updateLogMethods(t,e,c)},Object.keys(n).forEach(function(o){Object.defineProperty(t,o,{get:function(){return u(""+e+n[o].open)}})}),t.setLevel(r.getPersistedLevel()||c),i.updateLogMethods(t,e,c),t}},function(e,t,o){"use strict";var n=o(1),r=e.exports={},i=function(e){var t=Array.prototype.slice.call(arguments,1),o=t.concat(n.EOL).join("");console[e](o)};r.updateLogMethods=function(e,t,o){n.LOG_METHODS.forEach(function(n,r){r>=o?e[n]=i.bind(null,n,t):e[n]=function(){}})}},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children=[],e.webpackPolyfill=1),e}}])}); \ No newline at end of file diff --git a/dist/logatim.var.js b/dist/logatim.var.js deleted file mode 100644 index 54dfa67..0000000 --- a/dist/logatim.var.js +++ /dev/null @@ -1 +0,0 @@ -var logatim=function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return e[o].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";e.exports=n(4)("")},function(e,t){"use strict";e.exports={DEFAULT_LEVEL:"WARN",EOL:"",LOG_METHODS:["trace","debug","info","warn","error"],STORAGE_KEY:"logatimLevel",LEVELS:{TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5}}},function(e,t,n){(function(e){"use strict";function t(){var e={modifiers:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},colors:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39]},bgColors:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49]}};return e.colors.grey=e.colors.gray,Object.keys(e).forEach(function(t){var n=e[t];Object.keys(n).forEach(function(t){var o=n[t];e[t]=n[t]={open:"["+o[0]+"m",close:"["+o[1]+"m"}}),Object.defineProperty(e,t,{value:n,enumerable:!1})}),e}Object.defineProperty(e,"exports",{enumerable:!0,get:t})}).call(t,n(6)(e))},function(e,t,n){"use strict";var o=n(1),r=e.exports={};r.setLevel=function(e){if("string"==typeof e&&void 0!==r[e.toUpperCase()]&&(e=o.LEVELS[e.toUpperCase()]),"number"==typeof e&&e>=0&&e<=r.SILENT)return r.persistLevel(e),e;throw"logatim.setLevel() called with invalid level: "+e},r.persistLevel=function(e){var t=(o.LOG_METHODS[e]||"silent").toUpperCase(),n=o.STORAGE_KEY;GLOBAL[n]=t;try{return void(window.localStorage[n]=t)}catch(r){}try{window.document.cookie=encodeURIComponent(n)+"="+t+";"}catch(r){}},r.getPersistedLevel=function(){var e=void 0,t=o.STORAGE_KEY;try{e=window.localStorage[t]}catch(n){}if("undefined"==typeof e)try{var r=window.document.cookie,i=r.indexOf(encodeURIComponent(t)+"=");i&&(e=/^([^;]+)/.exec(r.slice(i))[1])}catch(n){}return void 0===o.LEVELS[e]&&(e=void 0),e=GLOBAL[t]}},function(e,t,n){"use strict";var o=n(2),r=n(3),i=n(5),c=3,a=e.exports=function(e){var t=function(t){return a(e+t)};return t.getLevel=function(){return c},t.setLevel=function(e){return c=e},Object.keys(o).forEach(function(n){Object.defineProperty(t,n,{get:function(){return a(""+e+o[n].open)}})}),t.setLevel(r.getPersistedLevel()||c),i.updateLogMethods(t,a,e,c),t}},function(e,t,n){"use strict";var o=n(1),r=e.exports={},i=function(e){var t=Array.prototype.slice.call(arguments,1),n=t.concat(o.EOL).join("");console[e](n)};r.updateLogMethods=function(e,t,n,r){o.LOG_METHODS.forEach(function(t,o){r>=o?e[t]=i.bind(null,t,n):e[t]=function(){}})}},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children=[],e.webpackPolyfill=1),e}}]); \ No newline at end of file diff --git a/dist/logatim.var.min.js b/dist/logatim.var.min.js index 54dfa67..762d14a 100644 --- a/dist/logatim.var.min.js +++ b/dist/logatim.var.min.js @@ -1 +1 @@ -var logatim=function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return e[o].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";e.exports=n(4)("")},function(e,t){"use strict";e.exports={DEFAULT_LEVEL:"WARN",EOL:"",LOG_METHODS:["trace","debug","info","warn","error"],STORAGE_KEY:"logatimLevel",LEVELS:{TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5}}},function(e,t,n){(function(e){"use strict";function t(){var e={modifiers:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},colors:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39]},bgColors:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49]}};return e.colors.grey=e.colors.gray,Object.keys(e).forEach(function(t){var n=e[t];Object.keys(n).forEach(function(t){var o=n[t];e[t]=n[t]={open:"["+o[0]+"m",close:"["+o[1]+"m"}}),Object.defineProperty(e,t,{value:n,enumerable:!1})}),e}Object.defineProperty(e,"exports",{enumerable:!0,get:t})}).call(t,n(6)(e))},function(e,t,n){"use strict";var o=n(1),r=e.exports={};r.setLevel=function(e){if("string"==typeof e&&void 0!==r[e.toUpperCase()]&&(e=o.LEVELS[e.toUpperCase()]),"number"==typeof e&&e>=0&&e<=r.SILENT)return r.persistLevel(e),e;throw"logatim.setLevel() called with invalid level: "+e},r.persistLevel=function(e){var t=(o.LOG_METHODS[e]||"silent").toUpperCase(),n=o.STORAGE_KEY;GLOBAL[n]=t;try{return void(window.localStorage[n]=t)}catch(r){}try{window.document.cookie=encodeURIComponent(n)+"="+t+";"}catch(r){}},r.getPersistedLevel=function(){var e=void 0,t=o.STORAGE_KEY;try{e=window.localStorage[t]}catch(n){}if("undefined"==typeof e)try{var r=window.document.cookie,i=r.indexOf(encodeURIComponent(t)+"=");i&&(e=/^([^;]+)/.exec(r.slice(i))[1])}catch(n){}return void 0===o.LEVELS[e]&&(e=void 0),e=GLOBAL[t]}},function(e,t,n){"use strict";var o=n(2),r=n(3),i=n(5),c=3,a=e.exports=function(e){var t=function(t){return a(e+t)};return t.getLevel=function(){return c},t.setLevel=function(e){return c=e},Object.keys(o).forEach(function(n){Object.defineProperty(t,n,{get:function(){return a(""+e+o[n].open)}})}),t.setLevel(r.getPersistedLevel()||c),i.updateLogMethods(t,a,e,c),t}},function(e,t,n){"use strict";var o=n(1),r=e.exports={},i=function(e){var t=Array.prototype.slice.call(arguments,1),n=t.concat(o.EOL).join("");console[e](n)};r.updateLogMethods=function(e,t,n,r){o.LOG_METHODS.forEach(function(t,o){r>=o?e[t]=i.bind(null,t,n):e[t]=function(){}})}},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children=[],e.webpackPolyfill=1),e}}]); \ No newline at end of file +var logatim=function(e){function t(n){if(o[n])return o[n].exports;var r=o[n]={exports:{},id:n,loaded:!1};return e[n].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var o={};return t.m=e,t.c=o,t.p="",t(0)}([function(e,t,o){"use strict";e.exports=o(4)("")},function(e,t){"use strict";e.exports={DEFAULT_LEVEL:"WARN",EOL:"",LOG_METHODS:["trace","debug","info","warn","error"],STORAGE_KEY:"logatimLevel",LEVELS:{TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5}}},function(e,t,o){(function(e){"use strict";function t(){var e={modifiers:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},colors:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39]},bgColors:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49]}};return e.colors.grey=e.colors.gray,Object.keys(e).forEach(function(t){var o=e[t];Object.keys(o).forEach(function(t){var n=o[t];e[t]=o[t]={open:"["+n[0]+"m",close:"["+n[1]+"m"}}),Object.defineProperty(e,t,{value:o,enumerable:!1})}),e}Object.defineProperty(e,"exports",{enumerable:!0,get:t})}).call(t,o(6)(e))},function(e,t,o){"use strict";var n=o(1),r=e.exports={};r.getLevel=function(e){return Object.keys(n.LEVELS)[e]},r.setLevel=function(e){if("string"==typeof e&&void 0!==n.LEVELS[e.toUpperCase()]&&(e=n.LEVELS[e.toUpperCase()]),"number"==typeof e&&e>=0&&e<=n.LEVELS.SILENT)return r.persistLevel(e),e;throw new Error("logatim.setLevel() called with invalid level: "+e)},r.persistLevel=function(e){var t=(n.LOG_METHODS[e]||"silent").toUpperCase(),o=n.STORAGE_KEY;GLOBAL[o]=t;try{return void(window.localStorage[o]=t)}catch(r){}try{window.document.cookie=encodeURIComponent(o)+"="+t+";"}catch(r){}},r.getPersistedLevel=function(){var e=void 0,t=n.STORAGE_KEY;try{e=window.localStorage[t]}catch(o){}if("undefined"==typeof e)try{var r=window.document.cookie,c=r.indexOf(encodeURIComponent(t)+"=");c&&(e=/^([^;]+)/.exec(r.slice(c))[1])}catch(o){}return void 0===n.LEVELS[e]&&(e=void 0),e=GLOBAL[t]}},function(e,t,o){"use strict";var n=o(2),r=o(3),c=o(5),i=3,a=e.exports=function(e){var t=function(t){return a(e+t)};return t.getLevel=function(){return r.getLevel(i)},t.setLevel=function(o){i=r.setLevel(o),c.updateLogMethods(t,e,i)},Object.keys(n).forEach(function(o){Object.defineProperty(t,o,{get:function(){return a(""+e+n[o].open)}})}),t.setLevel(r.getPersistedLevel()||i),c.updateLogMethods(t,e,i),t}},function(e,t,o){"use strict";var n=o(1),r=e.exports={},c=function(e){var t=Array.prototype.slice.call(arguments,1),o=t.concat(n.EOL).join("");console[e](o)};r.updateLogMethods=function(e,t,o){n.LOG_METHODS.forEach(function(n,r){r>=o?e[n]=c.bind(null,n,t):e[n]=function(){}})}},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children=[],e.webpackPolyfill=1),e}}]); \ No newline at end of file diff --git a/index.js b/index.js index 5044f42..04560d3 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -module.exports = require('./lib/logatim')('') \ No newline at end of file +module.exports = require('./lib/logatim')('') diff --git a/lib/constants.js b/lib/constants.js index f1ab09f..f96b436 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -1,7 +1,7 @@ module.exports = { DEFAULT_LEVEL: 'WARN', - EOL: '\u001b[49m\u001b[0m', - LOG_METHODS: ["trace", "debug", "info", "warn", "error"], + EOL: '\u001b[49m\u001b[0m', + LOG_METHODS: ['trace', 'debug', 'info', 'warn', 'error'], STORAGE_KEY: 'logatimLevel', LEVELS: { TRACE: 0, diff --git a/lib/levels.js b/lib/levels.js index e7b6eec..3addf32 100644 --- a/lib/levels.js +++ b/lib/levels.js @@ -4,24 +4,26 @@ const constants = require('./constants') const levels = module.exports = {} +levels.getLevel = level => Object.keys(constants.LEVELS)[level] + levels.setLevel = level => { - if (typeof level === "string" && levels[level.toUpperCase()] !== undefined) { + if (typeof level === 'string' && constants.LEVELS[level.toUpperCase()] !== undefined) { level = constants.LEVELS[level.toUpperCase()] } - if (typeof level === "number" && level >= 0 && level <= levels.SILENT) { + if (typeof level === 'number' && level >= 0 && level <= constants.LEVELS.SILENT) { levels.persistLevel(level) - + return level } else { - throw "logatim.setLevel() called with invalid level: " + level + throw new Error(`logatim.setLevel() called with invalid level: ${level}`) } } levels.persistLevel = (levelNum) => { let levelName = (constants.LOG_METHODS[levelNum] || 'silent').toUpperCase() let sk = constants.STORAGE_KEY - + // server side GLOBAL[sk] = levelName @@ -34,7 +36,7 @@ levels.persistLevel = (levelNum) => { // Use session cookie as fallback try { - window.document.cookie = encodeURIComponent(sk) + "=" + levelName + ";" + window.document.cookie = encodeURIComponent(sk) + '=' + levelName + ';' } catch (ignore) {} } @@ -52,7 +54,7 @@ levels.getPersistedLevel = () => { if (typeof storedLevel === 'undefined') { try { let cookie = window.document.cookie - let location = cookie.indexOf(encodeURIComponent(sk) + "=") + let location = cookie.indexOf(encodeURIComponent(sk) + '=') if (location) storedLevel = /^([^;]+)/.exec(cookie.slice(location))[1] } catch (ignore) {} @@ -63,7 +65,6 @@ levels.getPersistedLevel = () => { storedLevel = undefined } - // server side storedLevel = GLOBAL[sk] diff --git a/lib/logatim.js b/lib/logatim.js index 72458e3..5b831b2 100644 --- a/lib/logatim.js +++ b/lib/logatim.js @@ -10,8 +10,12 @@ const logatim = module.exports = message => { const speaker = str => logatim(message + str) // Leveling - speaker.getLevel = () => currentLevel - speaker.setLevel = (level) => currentLevel = level + speaker.getLevel = () => levels.getLevel(currentLevel) + + speaker.setLevel = (level) => { + currentLevel = levels.setLevel(level) + logs.updateLogMethods(speaker, message, currentLevel) + } // Colors Object.keys(ansi).forEach(style => { @@ -22,7 +26,7 @@ const logatim = module.exports = message => { // Refresh reachable methods speaker.setLevel(levels.getPersistedLevel() || currentLevel) - logs.updateLogMethods(speaker, logatim, message, currentLevel) + logs.updateLogMethods(speaker, message, currentLevel) return speaker } diff --git a/lib/logs.js b/lib/logs.js index 803228a..10312bb 100644 --- a/lib/logs.js +++ b/lib/logs.js @@ -11,9 +11,9 @@ const log = function (level) { console[level](output) } -logs.updateLogMethods = (speaker, logatim, message, currentLevel) => { +logs.updateLogMethods = (speaker, message, currentLevel) => { constants.LOG_METHODS.forEach((methodName, idx) => { - (idx <= currentLevel) + (idx >= currentLevel) ? speaker[methodName] = log.bind(null, methodName, message) : speaker[methodName] = function noop () {} }) diff --git a/package.json b/package.json index 4177bc1..a86138c 100644 --- a/package.json +++ b/package.json @@ -1,19 +1,16 @@ { "name": "logatim", - "version": "1.0.0", "description": "Isomorphic logger which implements log levels and ANSI styles", "main": "dist/logatim.umd.min.js", "scripts": { "start": "node index.js", - "test": "tape test/test-*.js", - "build": "node ./node_modules/webpack/bin/webpack.js -p", - "semantic-release": "semantic-release pre && npm publish && semantic-release post" - }, - "author": { - "name": "Rubén Sospedra", - "email": "hello@sospedra.me", - "url": "http://sospedra.me" + "test": "node_modules/.bin/tape test/test-*.js | node_modules/.bin/tap-spec", + "posttest": "node_modules/.bin/standard --verbose | node_modules/.bin/snazzy", + "build": "npm test && ./node_modules/.bin/webpack -p", + "changelog": "changelog edravis/logatim -m > CHANGELOG.md", + "semantic-release": "node_modules/.bin/semantic-release pre && npm publish && node_modules/.bin/semantic-release post" }, + "author": "Rubén Sospedra (http://sospedra.me)", "license": "ISC", "dependencies": { "ansi-styles": "^2.1.0" @@ -25,15 +22,42 @@ "cz-conventional-changelog": "^1.1.5", "parallel-webpack": "^1.0.0", "semantic-release": "^4.3.5", + "snazzy": "^2.0.1", + "standard": "^5.4.1", + "tap-spec": "^4.1.1", + "tape": "^4.4.0", "webpack": "^1.12.9" }, "repository": { "type": "git", - "url": "https://github.com/edravis/logatim.git" + "url": "git+https://github.com/edravis/logatim.git" }, "config": { "commitizen": { "path": "./node_modules/cz-conventional-changelog" } - } -} \ No newline at end of file + }, + "bugs": { + "url": "https://github.com/edravis/logatim/issues" + }, + "homepage": "https://github.com/edravis/logatim#readme", + "directories": { + "test": "test" + }, + "keywords": [ + "logger", + "logging", + "log", + "console.log", + "colors", + "styles", + "levels", + "isomorphic", + "server", + "side", + "client", + "side", + "node", + "browser" + ] +} diff --git a/test/test-levels.js b/test/test-levels.js index e69de29..094e4e5 100644 --- a/test/test-levels.js +++ b/test/test-levels.js @@ -0,0 +1,30 @@ +const test = require('tape') +const logatim = require('../index.js') + +test('get/set methods', t => { + t.plan(4) + + // access to methods + t.notEqual(logatim.getLevel, undefined, 'has acces to .getLevel()') + t.notEqual(logatim.setLevel, undefined, 'has acces to .setLevel()') + + // default value + t.equal(logatim.getLevel(), 'WARN', '.getLevel() by default is 3') + + // set level + logatim.setLevel('info') + t.equal(logatim.getLevel(), 'INFO', '.setLevel() can change the current level') +}) + +test('methods less than the current level should be nooped (not available)', t => { + t.plan(3) + + // different block scope + t.equal(logatim.getLevel(), 'INFO', '.getLevel() is still INFO in other block scope') + + // greater methods should be available + t.notEqual(logatim.warn.name, 'noop', '.warn() is greater than INFO an is available') + + // lesser methods should NOT be available (nooped) + t.equal(logatim.trace.name, 'noop', '.trace() is less than INFO an is NOT available (nooped)') +}) diff --git a/test/test-styles.js b/test/test-styles.js deleted file mode 100644 index e69de29..0000000 diff --git a/webpack.config.js b/webpack.config.js index c21008c..a25db99 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -22,6 +22,6 @@ const createConfig = options => ({ const variants = createVariants({ target: ['var', 'commonjs2', 'amd', 'umd'] -}, createConfig) +}, createConfig) -module.exports = variants \ No newline at end of file +module.exports = variants