logger: better context handling.
This commit is contained in:
parent
896ffdd3f5
commit
f7853aa639
@ -56,7 +56,7 @@ function RPC(node) {
|
|||||||
this.pool = node.pool;
|
this.pool = node.pool;
|
||||||
this.fees = node.fees;
|
this.fees = node.fees;
|
||||||
this.miner = node.miner;
|
this.miner = node.miner;
|
||||||
this.logger = node.logger;
|
this.logger = node.logger.context('rpc');
|
||||||
|
|
||||||
this.mining = false;
|
this.mining = false;
|
||||||
this.procLimit = 0;
|
this.procLimit = 0;
|
||||||
|
|||||||
@ -29,6 +29,7 @@ function Logger(options) {
|
|||||||
this.console = true;
|
this.console = true;
|
||||||
this.filename = null;
|
this.filename = null;
|
||||||
this.stream = null;
|
this.stream = null;
|
||||||
|
this.contexts = {};
|
||||||
|
|
||||||
this.init(options);
|
this.init(options);
|
||||||
}
|
}
|
||||||
@ -378,7 +379,14 @@ Logger.prototype.log = function log(level, module, args) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Logger.prototype.context = function context(module) {
|
Logger.prototype.context = function context(module) {
|
||||||
return new LoggerContext(this, module);
|
var context = this.contexts[module];
|
||||||
|
|
||||||
|
if (!context) {
|
||||||
|
context = new LoggerContext(this, module);
|
||||||
|
this.contexts[module] = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
return context;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -39,7 +39,7 @@ function HTTPServer(options) {
|
|||||||
|
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.network = this.options.network;
|
this.network = this.options.network;
|
||||||
this.logger = this.options.logger;
|
this.logger = this.options.logger.context('http');
|
||||||
this.walletdb = this.options.walletdb;
|
this.walletdb = this.options.walletdb;
|
||||||
|
|
||||||
this.server = new HTTPBase(this.options);
|
this.server = new HTTPBase(this.options);
|
||||||
|
|||||||
@ -45,7 +45,7 @@ function RPC(wdb) {
|
|||||||
|
|
||||||
this.wdb = wdb;
|
this.wdb = wdb;
|
||||||
this.network = wdb.network;
|
this.network = wdb.network;
|
||||||
this.logger = wdb.logger;
|
this.logger = wdb.logger.context('rpc');
|
||||||
this.client = wdb.client;
|
this.client = wdb.client;
|
||||||
|
|
||||||
this.wallet = null;
|
this.wallet = null;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user