Comparing version 0.3.0 to 0.4.0
35
bows.js
@@ -5,7 +5,20 @@ (function() { | ||
firefox = /firefox/i.test(navigator.userAgent), | ||
firebug = firefox && !!window.console.exception; | ||
firefoxVersion; | ||
return chrome || firebug; | ||
if (firefox) { | ||
var match = navigator.userAgent.match(/Firefox\/(\d+\.\d+)/); | ||
if (match && match[1] && Number(match[1])) { | ||
firefoxVersion = Number(match[1]); | ||
} | ||
} | ||
return chrome || firefoxVersion >= 31.0; | ||
} | ||
var yieldColor = function() { | ||
var goldenRatio = 0.618033988749895; | ||
hue += goldenRatio; | ||
hue = hue % 1; | ||
return hue * 360; | ||
}; | ||
var inNode = typeof window === 'undefined', | ||
@@ -19,15 +32,9 @@ ls = !inNode && window.localStorage, | ||
colorsSupported = ls.debugColors || checkColorSupport(), | ||
yieldColor, | ||
bows, | ||
debugRegex; | ||
bows = null, | ||
debugRegex = null; | ||
yieldColor = function() { | ||
var goldenRatio = 0.618033988749895; | ||
hue += goldenRatio; | ||
hue = hue % 1; | ||
return hue * 360; | ||
}; | ||
debugRegex = debug && debug[0]==='/' && new RegExp(debug.substring(1,debug.length-1)); | ||
var logLevels = ['log', 'debug', 'warn', 'error', 'info']; | ||
bows = function(str) { | ||
@@ -46,3 +53,3 @@ var msg, colorString, logfn; | ||
logfn = logger.log.bind(logger, msg, colorString); | ||
['log', 'debug', 'warn', 'error', 'info'].forEach(function (f) { | ||
logLevels.forEach(function (f) { | ||
logfn[f] = logger[f].bind(logger, msg, colorString); | ||
@@ -52,3 +59,3 @@ }); | ||
logfn = logger.log.bind(logger, msg); | ||
['log', 'debug', 'warn', 'error', 'info'].forEach(function (f) { | ||
logLevels.forEach(function (f) { | ||
logfn[f] = logger[f].bind(logger, msg); | ||
@@ -55,0 +62,0 @@ }); |
@@ -1,3 +0,2 @@ | ||
!function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.bows=e():"undefined"!=typeof global?global.bows=e():"undefined"!=typeof self&&(self.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(require,module,exports){ | ||
!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){ | ||
(function() { | ||
@@ -7,11 +6,24 @@ function checkColorSupport() { | ||
firefox = /firefox/i.test(navigator.userAgent), | ||
firebug = firefox && !!window.console.exception; | ||
firefoxVersion; | ||
return chrome || firebug; | ||
if (firefox) { | ||
var match = navigator.userAgent.match(/Firefox\/(\d+\.\d+)/); | ||
if (match && match[1] && Number(match[1])) { | ||
firefoxVersion = Number(match[1]); | ||
} | ||
} | ||
return chrome || firefoxVersion >= 31.0; | ||
} | ||
var yieldColor = function() { | ||
var goldenRatio = 0.618033988749895; | ||
hue += goldenRatio; | ||
hue = hue % 1; | ||
return hue * 360; | ||
}; | ||
var inNode = typeof window === 'undefined', | ||
ls = !inNode && window.localStorage, | ||
debug = ls.debug, | ||
logger = require('andlog'), | ||
logger = _dereq_('andlog'), | ||
hue = 0, | ||
@@ -21,15 +33,9 @@ padLength = 15, | ||
colorsSupported = ls.debugColors || checkColorSupport(), | ||
yieldColor, | ||
bows, | ||
debugRegex; | ||
bows = null, | ||
debugRegex = null; | ||
yieldColor = function() { | ||
var goldenRatio = 0.618033988749895; | ||
hue += goldenRatio; | ||
hue = hue % 1; | ||
return hue * 360; | ||
}; | ||
debugRegex = debug && debug[0]==='/' && new RegExp(debug.substring(1,debug.length-1)); | ||
var logLevels = ['log', 'debug', 'warn', 'error', 'info']; | ||
bows = function(str) { | ||
@@ -48,3 +54,3 @@ var msg, colorString, logfn; | ||
logfn = logger.log.bind(logger, msg, colorString); | ||
['log', 'debug', 'warn', 'error', 'info'].forEach(function (f) { | ||
logLevels.forEach(function (f) { | ||
logfn[f] = logger[f].bind(logger, msg, colorString); | ||
@@ -54,3 +60,3 @@ }); | ||
logfn = logger.log.bind(logger, msg); | ||
['log', 'debug', 'warn', 'error', 'info'].forEach(function (f) { | ||
logLevels.forEach(function (f) { | ||
logfn[f] = logger[f].bind(logger, msg); | ||
@@ -76,3 +82,3 @@ }); | ||
},{"andlog":2}],2:[function(require,module,exports){ | ||
},{"andlog":2}],2:[function(_dereq_,module,exports){ | ||
// follow @HenrikJoreteg and @andyet if you like this ;) | ||
@@ -109,3 +115,2 @@ (function () { | ||
(1) | ||
}); | ||
; | ||
}); |
@@ -1,1 +0,1 @@ | ||
!function(n){"object"==typeof exports?module.exports=n():"function"==typeof define&&define.amd?define(n):"undefined"!=typeof window?window.bows=n():"undefined"!=typeof global?global.bows=n():"undefined"!=typeof self&&(self.bows=n())}(function(){return function n(o,e,r){function i(f,d){if(!e[f]){if(!o[f]){var u="function"==typeof require&&require;if(!d&&u)return u(f,!0);if(t)return t(f,!0);throw new Error("Cannot find module '"+f+"'")}var l=e[f]={exports:{}};o[f][0].call(l.exports,function(n){var e=o[f][1][n];return i(e?e:n)},l,l.exports,n,o,e,r)}return e[f].exports}for(var t="function"==typeof require&&require,f=0;f<r.length;f++)i(r[f]);return i}({1:[function(n,o){!function(){function e(){var n=!!window.chrome,o=/firefox/i.test(navigator.userAgent),e=o&&!!window.console.exception;return n||e}var r,i,t,f="undefined"==typeof window,d=!f&&window.localStorage,u=d.debug,l=n("andlog"),c=0,a=15,w=function(){},s=d.debugColors||e();r=function(){var n=.618033988749895;return c+=n,c%=1,360*c},t=u&&"/"===u[0]&&new RegExp(u.substring(1,u.length-1)),i=function(n){var o,e,i;if(o=n.slice(0,a),o+=Array(a+3-o.length).join(" ")+"|",t&&!n.match(t))return w;if(s){var f=r();o="%c"+o,e="color: hsl("+f+",99%,40%); font-weight: bold",i=l.log.bind(l,o,e),["log","debug","warn","error","info"].forEach(function(n){i[n]=l[n].bind(l,o,e)})}else i=l.log.bind(l,o),["log","debug","warn","error","info"].forEach(function(n){i[n]=l[n].bind(l,o)});return i},i.config=function(n){n.padLength&&(this.padLength=n.padLength)},"undefined"!=typeof o?o.exports=i:window.bows=i}.call()},{andlog:2}],2:[function(n,o,e){!function(){var n="undefined"==typeof window,r=!n&&window.localStorage,i={};if(n)return o.exports=console,void 0;if(r&&r.debug&&window.console)i=window.console;else for(var t="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),f=t.length,d=function(){};f--;)i[t[f]]=d;"undefined"!=typeof e?o.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 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 d+=n,d%=1,360*d},i="undefined"==typeof window,t=!i&&window.localStorage,f=t.debug,u=n("andlog"),d=0,l=15,a=function(){},c=t.debugColors||o(),s=null,g=null;g=f&&"/"===f[0]&&new RegExp(f.substring(1,f.length-1));var p=["log","debug","warn","error","info"];s=function(n){var e,o,i;if(e=n.slice(0,l),e+=Array(l+3-e.length).join(" ")+"|",g&&!n.match(g))return a;if(c){var t=r();e="%c"+e,o="color: hsl("+t+",99%,40%); font-weight: bold",i=u.log.bind(u,e,o),p.forEach(function(n){i[n]=u[n].bind(u,e,o)})}else i=u.log.bind(u,e),p.forEach(function(n){i[n]=u[n].bind(u,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;if(r&&r.debug&&window.console)i=window.console;else for(var t="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),f=t.length,u=function(){};f--;)i[t[f]]=u;"undefined"!=typeof o?e.exports=i:window.console=i}()},{}]},{},[1])(1)}); |
{ | ||
"name": "bows", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Rainbowed console logs for chrome in development", | ||
"main": "bows.js", | ||
"scripts": { | ||
"test": "node test.js" | ||
"build": "node build.js", | ||
"test": "node build.js && phantomjs test/index.js" | ||
}, | ||
@@ -14,2 +15,3 @@ "dependencies": { | ||
"browserify": "", | ||
"phantomjs": "^1.9.7-8", | ||
"uglify-js": "~2.3.6" | ||
@@ -16,0 +18,0 @@ }, |
# Bows | ||
![Colors](https://raw.github.com/latentflip/bows/master/example/cols.png) | ||
Safe, production happy, colourful logging for chrome - makes reading your logs _much_ easier. | ||
Safe, production happy, colourful logging - makes reading your logs _much_ easier. | ||
@@ -31,3 +31,7 @@ | ||
# Browser Support | ||
* Works in all reasonable browsers | ||
* Supports colors in chrome, opera, firefox >= 31.0 | ||
## Usage | ||
@@ -69,2 +73,16 @@ - Works great in browserify and the browser. | ||
## Test | ||
__Status:__ [![Build Status](https://travis-ci.org/latentflip/bows.svg?branch=master)](https://travis-ci.org/latentflip/bows) | ||
This project uses `phantomjs` for tests. To run the tests install the development dependencies and then run: | ||
```bash | ||
npm test | ||
``` | ||
### New tests | ||
Add a file in `test`, refer to enabled.html/disabled.html, then add the script to the array in test/index.js. | ||
## License & Credits | ||
@@ -74,4 +92,7 @@ | ||
Copyright [@Philip\_Roberts](http://twitter.com/philip\_roberts) [latentflip.com](http://latentflip.com). | ||
Copyright [@philip\_roberts](http://twitter.com/philip\_roberts) / [latentflip.com](http://latentflip.com). | ||
With contributions from: | ||
* [@lloydwatkin](https://twitter.com/lloydwatkin). | ||
Bows depends on [andlog](http://github.com/henrikjoreteg/andlog), a nice little logging module by [@HenrikJoreteg](https://twitter.com/henrikjoreteg). | ||
@@ -89,4 +110,5 @@ | ||
#edit bows.js | ||
npm test | ||
node build.js #build dist/bows.js and dist/bows.min.js | ||
``` | ||
79167
20
258
111
3