Comparing version 0.5.0 to 0.6.0
17
bows.js
@@ -28,2 +28,3 @@ (function() { | ||
logger = require('andlog'), | ||
bind = Function.prototype.bind, | ||
hue = 0, | ||
@@ -40,2 +41,7 @@ padLength = 15, | ||
//Noop should noop | ||
for (var i = 0, ii = logLevels.length; i < ii; i++) { | ||
noop[ logLevels[i] ] = noop; | ||
} | ||
bows = function(str) { | ||
@@ -48,2 +54,4 @@ var msg, colorString, logfn; | ||
if (!bind) return noop; | ||
if (colorsSupported) { | ||
@@ -54,10 +62,11 @@ var color = yieldColor(); | ||
logfn = logger.log.bind(logger, msg, colorString); | ||
logfn = bind.call(logger.log, logger, msg, colorString); | ||
logLevels.forEach(function (f) { | ||
logfn[f] = logger[f].bind(logger, msg, colorString); | ||
logfn[f] = bind.call(logger[f] || logfn, logger, msg, colorString); | ||
}); | ||
} else { | ||
logfn = logger.log.bind(logger, msg); | ||
logfn = bind.call(logger.log, logger, msg); | ||
logLevels.forEach(function (f) { | ||
logfn[f] = logger[f].bind(logger, msg); | ||
logfn[f] = bind.call(logger[f] || logfn, logger, msg); | ||
}); | ||
@@ -64,0 +73,0 @@ } |
@@ -29,2 +29,3 @@ !function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.bows=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){ | ||
logger = _dereq_('andlog'), | ||
bind = Function.prototype.bind, | ||
hue = 0, | ||
@@ -41,2 +42,7 @@ padLength = 15, | ||
//Noop should noop | ||
for (var i = 0, ii = logLevels.length; i < ii; i++) { | ||
noop[ logLevels[i] ] = noop; | ||
} | ||
bows = function(str) { | ||
@@ -49,2 +55,4 @@ var msg, colorString, logfn; | ||
if (!bind) return noop; | ||
if (colorsSupported) { | ||
@@ -55,10 +63,11 @@ var color = yieldColor(); | ||
logfn = logger.log.bind(logger, msg, colorString); | ||
logfn = bind.call(logger.log, logger, msg, colorString); | ||
logLevels.forEach(function (f) { | ||
logfn[f] = logger[f].bind(logger, msg, colorString); | ||
logfn[f] = bind.call(logger[f] || logfn, logger, msg, colorString); | ||
}); | ||
} else { | ||
logfn = logger.log.bind(logger, msg); | ||
logfn = bind.call(logger.log, logger, msg); | ||
logLevels.forEach(function (f) { | ||
logfn[f] = logger[f].bind(logger, msg); | ||
logfn[f] = bind.call(logger[f] || logfn, logger, msg); | ||
}); | ||
@@ -65,0 +74,0 @@ } |
@@ -1,1 +0,1 @@ | ||
!function(n){if("object"==typeof exports)module.exports=n();else if("function"==typeof define&&define.amd)define(n);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.bows=n()}}(function(){return function n(e,o,r){function i(f,u){if(!o[f]){if(!e[f]){var d="function"==typeof require&&require;if(!u&&d)return d(f,!0);if(t)return t(f,!0);throw new Error("Cannot find module '"+f+"'")}var l=o[f]={exports:{}};e[f][0].call(l.exports,function(n){var o=e[f][1][n];return i(o?o:n)},l,l.exports,n,e,o,r)}return o[f].exports}for(var t="function"==typeof require&&require,f=0;f<r.length;f++)i(r[f]);return i}({1:[function(n,e){!function(){function o(){var n,e=!!window.chrome,o=/firefox/i.test(navigator.userAgent);if(o){var r=navigator.userAgent.match(/Firefox\/(\d+\.\d+)/);r&&r[1]&&Number(r[1])&&(n=Number(r[1]))}return e||n>=31}var r=function(){var n=.618033988749895;return l+=n,l%=1,360*l},i="undefined"==typeof window,t=!i&&window.localStorage,f=t.andlogKey||"debug",u=t[f],d=n("andlog"),l=0,a=15,c=function(){},g=t.debugColors||o(),s=null,p=null;p=u&&"/"===u[0]&&new RegExp(u.substring(1,u.length-1));var w=["log","debug","warn","error","info"];s=function(n){var e,o,i;if(e=n.slice(0,a),e+=Array(a+3-e.length).join(" ")+"|",p&&!n.match(p))return c;if(g){var t=r();e="%c"+e,o="color: hsl("+t+",99%,40%); font-weight: bold",i=d.log.bind(d,e,o),w.forEach(function(n){i[n]=d[n].bind(d,e,o)})}else i=d.log.bind(d,e),w.forEach(function(n){i[n]=d[n].bind(d,e)});return i},s.config=function(n){n.padLength&&(this.padLength=n.padLength)},"undefined"!=typeof e?e.exports=s:window.bows=s}.call()},{andlog:2}],2:[function(n,e,o){!function(){var n="undefined"==typeof window,r=!n&&window.localStorage,i={};if(n)return e.exports=console,void 0;var t=r.andlogKey||"debug";if(r&&r[t]&&window.console)i=window.console;else for(var f="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),u=f.length,d=function(){};u--;)i[f[u]]=d;"undefined"!=typeof o?e.exports=i:window.console=i}()},{}]},{},[1])(1)}); | ||
!function(n){if("object"==typeof exports)module.exports=n();else if("function"==typeof define&&define.amd)define(n);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.bows=n()}}(function(){return function n(e,o,r){function t(f,u){if(!o[f]){if(!e[f]){var l="function"==typeof require&&require;if(!u&&l)return l(f,!0);if(i)return i(f,!0);throw new Error("Cannot find module '"+f+"'")}var d=o[f]={exports:{}};e[f][0].call(d.exports,function(n){var o=e[f][1][n];return t(o?o:n)},d,d.exports,n,e,o,r)}return o[f].exports}for(var i="function"==typeof require&&require,f=0;f<r.length;f++)t(r[f]);return t}({1:[function(n,e){!function(){function o(){var n,e=!!window.chrome,o=/firefox/i.test(navigator.userAgent);if(o){var r=navigator.userAgent.match(/Firefox\/(\d+\.\d+)/);r&&r[1]&&Number(r[1])&&(n=Number(r[1]))}return e||n>=31}var r=function(){var n=.618033988749895;return a+=n,a%=1,360*a},t="undefined"==typeof window,i=!t&&window.localStorage,f=i.andlogKey||"debug",u=i[f],l=n("andlog"),d=Function.prototype.bind,a=0,c=15,g=function(){},p=i.debugColors||o(),s=null,w=null;w=u&&"/"===u[0]&&new RegExp(u.substring(1,u.length-1));for(var v=["log","debug","warn","error","info"],h=0,b=v.length;b>h;h++)g[v[h]]=g;s=function(n){var e,o,t;if(e=n.slice(0,c),e+=Array(c+3-e.length).join(" ")+"|",w&&!n.match(w))return g;if(!d)return g;if(p){var i=r();e="%c"+e,o="color: hsl("+i+",99%,40%); font-weight: bold",t=d.call(l.log,l,e,o),v.forEach(function(n){t[n]=d.call(l[n]||t,l,e,o)})}else t=d.call(l.log,l,e),v.forEach(function(n){t[n]=d.call(l[n]||t,l,e)});return t},s.config=function(n){n.padLength&&(this.padLength=n.padLength)},"undefined"!=typeof e?e.exports=s:window.bows=s}.call()},{andlog:2}],2:[function(n,e,o){!function(){var n="undefined"==typeof window,r=!n&&window.localStorage,t={};if(n)return e.exports=console,void 0;var i=r.andlogKey||"debug";if(r&&r[i]&&window.console)t=window.console;else for(var f="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),u=f.length,l=function(){};u--;)t[f[u]]=l;"undefined"!=typeof o?e.exports=t:window.console=t}()},{}]},{},[1])(1)}); |
{ | ||
"name": "bows", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "Rainbowed console logs for chrome in development", | ||
@@ -5,0 +5,0 @@ "main": "bows.js", |
@@ -27,3 +27,3 @@ # Bows | ||
* Easily create prefixes for your logs, so that you can distinguish between logs from different parts of your app easily. | ||
* In chrome prefixes will be color coded for even easier identification. | ||
* If supported, prefixes will be color coded for even easier identification. | ||
* Can be safely used in production, as logs will be disabled for your users, but can be enabled by you with a local storage flag. | ||
@@ -30,0 +30,0 @@ * Greppable logs by setting `localStorage.debug = /Foo/` to only display logs for modules matching the regex to help you focus in development. |
Sorry, the diff of this file is not supported yet
80693
274