-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
24 lines (23 loc) · 745 Bytes
/
index.js
File metadata and controls
24 lines (23 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
* index.js
* Copyright (C) 2017 Bradley McCrorey <brad@projectpixelpress.com>
*
* UNLICENSED
*/
module.exports = function() {
let prefix = '';
if (require.resolve('cluster')) prefix = 'C: '+process.pid;
['log', 'warn'].forEach(function(method) {
var old = console[method];
console[method] = function() {
var stack = (new Error()).stack.split(/\n/);
// Chrome includes a single "Error" line, FF doesn't.
if (stack[0].indexOf('Error') === 0) {
stack = stack.slice(1);
}
var args = [].slice.apply(arguments).concat([stack[1].trim()]);
args.unshift(prefix);
return old.apply(console, args);
};
});
}