[Pkg-javascript-commits] [node-debug] 03/18: Imported Upstream version 2.0.0
Leo Iannacone
l3on-guest at moszumanska.debian.org
Sat Oct 4 14:20:56 UTC 2014
This is an automated email from the git hooks/post-receive script.
l3on-guest pushed a commit to branch master
in repository node-debug.
commit 21a0006594b3d93d6eb827d67035965248737bb4
Author: Leo Iannacone <l3on at ubuntu.com>
Date: Sat Oct 4 14:37:48 2014 +0200
Imported Upstream version 2.0.0
---
History.md | 24 ++++
Readme.md | 5 +-
browser.js | 17 +--
component.json | 2 +-
debug.js | 4 +-
dist/debug.js | 308 ++++++++++++++++++++++++++-------------------------
example/browser.html | 5 +-
node.js | 4 +-
package.json | 4 +-
9 files changed, 201 insertions(+), 172 deletions(-)
diff --git a/History.md b/History.md
index 42139a8..79429ff 100644
--- a/History.md
+++ b/History.md
@@ -1,4 +1,28 @@
+2.0.0 / 2014-09-01
+==================
+
+ * package: update "browserify" to v5.11.0
+ * node: use stderr rather than stdout for logging (#29, @stephenmathieson)
+
+1.0.4 / 2014-07-15
+==================
+
+ * dist: recompile
+ * example: remove `console.info()` log usage
+ * example: add "Content-Type" UTF-8 header to browser example
+ * browser: place %c marker after the space character
+ * browser: reset the "content" color via `color: inherit`
+ * browser: add colors support for Firefox >= v31
+ * debug: prefer an instance `log()` function over the global one (#119)
+ * Readme: update documentation about styled console logs for FF v31 (#116, @wryk)
+
+1.0.3 / 2014-07-09
+==================
+
+ * Add support for multiple wildcards in namespaces (#122, @seegno)
+ * browser: fix lint
+
1.0.2 / 2014-06-10
==================
diff --git a/Readme.md b/Readme.md
index e3607db..e59b9ad 100644
--- a/Readme.md
+++ b/Readme.md
@@ -91,7 +91,10 @@ setInterval(function(){
#### Web Inspector Colors
Colors are also enabled on "Web Inspectors" that understand the `%c` formatting
- option. These are WebKit web inspectors, and the Firebug plugin for Firefox.
+ option. These are WebKit web inspectors, Firefox ([since version
+ 31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/))
+ and the Firebug plugin for Firefox (any version).
+
Colored output looks something like:
![](https://cloud.githubusercontent.com/assets/71256/3139768/b98c5fd8-e8ef-11e3-862a-f7253b6f47c6.png)
diff --git a/browser.js b/browser.js
index 41d957c..ce6369f 100644
--- a/browser.js
+++ b/browser.js
@@ -26,9 +26,9 @@ exports.colors = [
];
/**
- * Currently only WebKit-based Web Inspectors and the Firebug
- * extension (*not* the built-in Firefox web inpector) are
- * known to support "%c" CSS customizations.
+ * Currently only WebKit-based Web Inspectors, Firefox >= v31,
+ * and the Firebug extension (any Firefox version) are known
+ * to support "%c" CSS customizations.
*
* TODO: add a `localStorage` variable to explicitly enable/disable colors
*/
@@ -37,7 +37,10 @@ function useColors() {
// is webkit? http://stackoverflow.com/a/16459606/376773
return ('WebkitAppearance' in document.documentElement.style) ||
// is firebug? http://stackoverflow.com/a/398120/376773
- (window.console && (console.firebug || (console.exception && console.table)));
+ (window.console && (console.firebug || (console.exception && console.table))) ||
+ // is firefox >= v31?
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
+ (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31);
}
/**
@@ -61,15 +64,15 @@ function formatArgs() {
args[0] = (useColors ? '%c' : '')
+ this.namespace
- + (useColors ? '%c ' : ' ')
+ + (useColors ? ' %c' : ' ')
+ args[0]
+ (useColors ? '%c ' : ' ')
+ '+' + exports.humanize(this.diff);
- if (!useColors) return args
+ if (!useColors) return args;
var c = 'color: ' + this.color;
- args = [args[0], c, ''].concat(Array.prototype.slice.call(args, 1));
+ args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1));
// the final "%c" is somewhat tricky, because there could be other
// arguments passed either before or after the %c, so we need to
diff --git a/component.json b/component.json
index dfb0311..db1ceed 100644
--- a/component.json
+++ b/component.json
@@ -2,7 +2,7 @@
"name": "debug",
"repo": "visionmedia/debug",
"description": "small debugging utility",
- "version": "1.0.2",
+ "version": "2.0.0",
"keywords": [
"debug",
"log",
diff --git a/debug.js b/debug.js
index c514fb7..7571a86 100644
--- a/debug.js
+++ b/debug.js
@@ -113,7 +113,7 @@ function debug(namespace) {
if ('function' === typeof exports.formatArgs) {
args = exports.formatArgs.apply(self, args);
}
- var logFn = exports.log || enabled.log || console.log.bind(console);
+ var logFn = enabled.log || exports.log || console.log.bind(console);
logFn.apply(self, args);
}
enabled.enabled = true;
@@ -141,7 +141,7 @@ function enable(namespaces) {
for (var i = 0; i < len; i++) {
if (!split[i]) continue; // ignore empty strings
- namespaces = split[i].replace('*', '.*?');
+ namespaces = split[i].replace(/\*/g, '.*?');
if (namespaces[0] === '-') {
exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
} else {
diff --git a/dist/debug.js b/dist/debug.js
index 3fa8ae0..6045bd2 100644
--- a/dist/debug.js
+++ b/dist/debug.js
@@ -1,150 +1,4 @@
-!function(e){if("object"==typeof exports&&"undefined"!=typeof module)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.debug=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 [...]
-
-/**
- * This is the web browser implementation of `debug()`.
- *
- * Expose `debug()` as the module.
- */
-
-exports = module.exports = _dereq_('./debug');
-exports.log = log;
-exports.formatArgs = formatArgs;
-exports.save = save;
-exports.load = load;
-exports.useColors = useColors;
-
-/**
- * Colors.
- */
-
-exports.colors = [
- 'lightseagreen',
- 'forestgreen',
- 'goldenrod',
- 'dodgerblue',
- 'darkorchid',
- 'crimson'
-];
-
-/**
- * Currently only WebKit-based Web Inspectors and the Firebug
- * extension (*not* the built-in Firefox web inpector) are
- * known to support "%c" CSS customizations.
- *
- * TODO: add a `localStorage` variable to explicitly enable/disable colors
- */
-
-function useColors() {
- // is webkit? http://stackoverflow.com/a/16459606/376773
- return ('WebkitAppearance' in document.documentElement.style) ||
- // is firebug? http://stackoverflow.com/a/398120/376773
- (window.console && (console.firebug || (console.exception && console.table)));
-}
-
-/**
- * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
- */
-
-exports.formatters.j = function(v) {
- return JSON.stringify(v);
-};
-
-
-/**
- * Colorize log arguments if enabled.
- *
- * @api public
- */
-
-function formatArgs() {
- var args = arguments;
- var useColors = this.useColors;
-
- args[0] = (useColors ? '%c' : '')
- + this.namespace
- + (useColors ? '%c ' : ' ')
- + args[0]
- + (useColors ? '%c ' : ' ')
- + '+' + exports.humanize(this.diff);
-
- if (!useColors) return args
-
- var c = 'color: ' + this.color;
- args = [args[0], c, ''].concat(Array.prototype.slice.call(args, 1));
-
- // the final "%c" is somewhat tricky, because there could be other
- // arguments passed either before or after the %c, so we need to
- // figure out the correct index to insert the CSS into
- var index = 0;
- var lastC = 0;
- args[0].replace(/%[a-z%]/g, function(match) {
- if ('%%' === match) return;
- index++;
- if ('%c' === match) {
- // we only are interested in the *last* %c
- // (the user may have provided their own)
- lastC = index;
- }
- });
-
- args.splice(lastC, 0, c);
- return args;
-}
-
-/**
- * Invokes `console.log()` when available.
- * No-op when `console.log` is not a "function".
- *
- * @api public
- */
-
-function log() {
- // This hackery is required for IE8,
- // where the `console.log` function doesn't have 'apply'
- return 'object' == typeof console
- && 'function' == typeof console.log
- && Function.prototype.apply.call(console.log, console, arguments);
-}
-
-/**
- * Save `namespaces`.
- *
- * @param {String} namespaces
- * @api private
- */
-
-function save(namespaces) {
- try {
- if (null == namespaces) {
- localStorage.removeItem('debug');
- } else {
- localStorage.debug = namespaces;
- }
- } catch(e) {}
-}
-
-/**
- * Load `namespaces`.
- *
- * @return {String} returns the previously persisted debug modes
- * @api private
- */
-
-function load() {
- var r;
- try {
- r = localStorage.debug;
- } catch(e) {}
- return r;
-}
-
-/**
- * Enable namespaces listed in `localStorage.debug` initially.
- */
-
-exports.enable(load());
-
-},{"./debug":2}],2:[function(_dereq_,module,exports){
+!function(e){if("object"==typeof exports&&"undefined"!=typeof module)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.debug=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);var f=new Error("Cannot find [...]
/**
* This is the common logic for both the Node.js and web browser
@@ -158,7 +12,7 @@ exports.coerce = coerce;
exports.disable = disable;
exports.enable = enable;
exports.enabled = enabled;
-exports.humanize = _dereq_('ms');
+exports.humanize = require('ms');
/**
* The currently active debug mode names, and names to skip.
@@ -260,7 +114,7 @@ function debug(namespace) {
if ('function' === typeof exports.formatArgs) {
args = exports.formatArgs.apply(self, args);
}
- var logFn = exports.log || enabled.log || console.log.bind(console);
+ var logFn = enabled.log || exports.log || console.log.bind(console);
logFn.apply(self, args);
}
enabled.enabled = true;
@@ -288,7 +142,7 @@ function enable(namespaces) {
for (var i = 0; i < len; i++) {
if (!split[i]) continue; // ignore empty strings
- namespaces = split[i].replace('*', '.*?');
+ namespaces = split[i].replace(/\*/g, '.*?');
if (namespaces[0] === '-') {
exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
} else {
@@ -343,7 +197,7 @@ function coerce(val) {
return val;
}
-},{"ms":3}],3:[function(_dereq_,module,exports){
+},{"ms":2}],2:[function(require,module,exports){
/**
* Helpers.
*/
@@ -456,6 +310,154 @@ function plural(ms, n, name) {
return Math.ceil(ms / n) + ' ' + name + 's';
}
-},{}]},{},[1])
-(1)
+},{}],3:[function(require,module,exports){
+
+/**
+ * This is the web browser implementation of `debug()`.
+ *
+ * Expose `debug()` as the module.
+ */
+
+exports = module.exports = require('./debug');
+exports.log = log;
+exports.formatArgs = formatArgs;
+exports.save = save;
+exports.load = load;
+exports.useColors = useColors;
+
+/**
+ * Colors.
+ */
+
+exports.colors = [
+ 'lightseagreen',
+ 'forestgreen',
+ 'goldenrod',
+ 'dodgerblue',
+ 'darkorchid',
+ 'crimson'
+];
+
+/**
+ * Currently only WebKit-based Web Inspectors, Firefox >= v31,
+ * and the Firebug extension (any Firefox version) are known
+ * to support "%c" CSS customizations.
+ *
+ * TODO: add a `localStorage` variable to explicitly enable/disable colors
+ */
+
+function useColors() {
+ // is webkit? http://stackoverflow.com/a/16459606/376773
+ return ('WebkitAppearance' in document.documentElement.style) ||
+ // is firebug? http://stackoverflow.com/a/398120/376773
+ (window.console && (console.firebug || (console.exception && console.table))) ||
+ // is firefox >= v31?
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
+ (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31);
+}
+
+/**
+ * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
+ */
+
+exports.formatters.j = function(v) {
+ return JSON.stringify(v);
+};
+
+
+/**
+ * Colorize log arguments if enabled.
+ *
+ * @api public
+ */
+
+function formatArgs() {
+ var args = arguments;
+ var useColors = this.useColors;
+
+ args[0] = (useColors ? '%c' : '')
+ + this.namespace
+ + (useColors ? ' %c' : ' ')
+ + args[0]
+ + (useColors ? '%c ' : ' ')
+ + '+' + exports.humanize(this.diff);
+
+ if (!useColors) return args;
+
+ var c = 'color: ' + this.color;
+ args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1));
+
+ // the final "%c" is somewhat tricky, because there could be other
+ // arguments passed either before or after the %c, so we need to
+ // figure out the correct index to insert the CSS into
+ var index = 0;
+ var lastC = 0;
+ args[0].replace(/%[a-z%]/g, function(match) {
+ if ('%%' === match) return;
+ index++;
+ if ('%c' === match) {
+ // we only are interested in the *last* %c
+ // (the user may have provided their own)
+ lastC = index;
+ }
+ });
+
+ args.splice(lastC, 0, c);
+ return args;
+}
+
+/**
+ * Invokes `console.log()` when available.
+ * No-op when `console.log` is not a "function".
+ *
+ * @api public
+ */
+
+function log() {
+ // This hackery is required for IE8,
+ // where the `console.log` function doesn't have 'apply'
+ return 'object' == typeof console
+ && 'function' == typeof console.log
+ && Function.prototype.apply.call(console.log, console, arguments);
+}
+
+/**
+ * Save `namespaces`.
+ *
+ * @param {String} namespaces
+ * @api private
+ */
+
+function save(namespaces) {
+ try {
+ if (null == namespaces) {
+ localStorage.removeItem('debug');
+ } else {
+ localStorage.debug = namespaces;
+ }
+ } catch(e) {}
+}
+
+/**
+ * Load `namespaces`.
+ *
+ * @return {String} returns the previously persisted debug modes
+ * @api private
+ */
+
+function load() {
+ var r;
+ try {
+ r = localStorage.debug;
+ } catch(e) {}
+ return r;
+}
+
+/**
+ * Enable namespaces listed in `localStorage.debug` initially.
+ */
+
+exports.enable(load());
+
+},{"./debug":1}]},{},[3])(3)
});
\ No newline at end of file
diff --git a/example/browser.html b/example/browser.html
index c0b534a..0090418 100644
--- a/example/browser.html
+++ b/example/browser.html
@@ -2,6 +2,7 @@
<html>
<head>
<title>debug()</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="../dist/debug.js"></script>
<script>
// type debug.enable('*') in
@@ -10,10 +11,6 @@
var a = debug('worker:a');
var b = debug('worker:b');
- // set all output to go via console.info
- // instead of console.log
- debug.log = console.info.bind(console);
-
setInterval(function(){
a('doing some work');
}, 1000);
diff --git a/node.js b/node.js
index c94f7d1..db86f64 100644
--- a/node.js
+++ b/node.js
@@ -87,11 +87,11 @@ function formatArgs() {
}
/**
- * Invokes `console.log()` with the specified arguments.
+ * Invokes `console.error()` with the specified arguments.
*/
function log() {
- return console.log.apply(console, arguments);
+ return console.error.apply(console, arguments);
}
/**
diff --git a/package.json b/package.json
index 2ca9eac..05b55d2 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "debug",
- "version": "1.0.2",
+ "version": "2.0.0",
"repository": {
"type": "git",
"url": "git://github.com/visionmedia/debug.git"
@@ -19,7 +19,7 @@
"ms": "0.6.2"
},
"devDependencies": {
- "browserify": "4.1.6",
+ "browserify": "5.11.0",
"mocha": "*"
},
"main": "./node.js",
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-debug.git
More information about the Pkg-javascript-commits
mailing list