debug file flag.
This commit is contained in:
parent
ad173d0f22
commit
26969d823a
12
lib/bcoin.js
12
lib/bcoin.js
@ -11,11 +11,8 @@ bcoin.isBrowser =
|
||||
(typeof process !== 'undefined' && process.browser)
|
||||
|| typeof window !== 'undefined';
|
||||
|
||||
if (process.env.BCOIN_DEBUG) {
|
||||
bcoin.debug = process.env.BCOIN_DEBUG;
|
||||
if (bcoin.debug === '0' || bcoin.debug === '1')
|
||||
bcoin.debug = +bcoin.debug === 1;
|
||||
}
|
||||
bcoin.debug = +process.env.BCOIN_DEBUG === 1;
|
||||
bcoin.debugFile = +process.env.BCOIN_DEBUGFILE !== 0;
|
||||
|
||||
bcoin.bn = require('bn.js');
|
||||
bcoin.elliptic = require('elliptic');
|
||||
@ -45,11 +42,6 @@ if (bcoin.fs) {
|
||||
}
|
||||
}
|
||||
|
||||
if (bcoin.fs) {
|
||||
bcoin._debug = bcoin.fs.createWriteStream(
|
||||
bcoin.dir + '/debug.log', { flags: 'w' });
|
||||
}
|
||||
|
||||
bcoin.ecdsa = bcoin.elliptic.ec('secp256k1');
|
||||
assert(!bcoin.ecdsa.signature);
|
||||
bcoin.ecdsa.signature = require('elliptic/lib/elliptic/ec/signature');
|
||||
|
||||
@ -764,9 +764,13 @@ utils.debug = function debug() {
|
||||
process.stdout.write(msg);
|
||||
}
|
||||
|
||||
if (bcoin._debug) {
|
||||
if (bcoin.debugFile && bcoin.fs) {
|
||||
if (!bcoin._debug) {
|
||||
bcoin._debug = bcoin.fs.createWriteStream(
|
||||
bcoin.dir + '/debug.log', { flags: 'a' });
|
||||
}
|
||||
msg = utils.format(args, false);
|
||||
bcoin._debug.write(msg);
|
||||
bcoin._debug.write(process.pid + ': ' + msg);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user