mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 14:35:52 +00:00
Added different logging style when running in browser.
This commit is contained in:
@@ -22,6 +22,8 @@ var Amount = require('./amount.js').Amount;
|
||||
var Currency = require('./amount.js').Currency;
|
||||
var UInt160 = require('./amount.js').UInt160;
|
||||
|
||||
var utils = require('./utils');
|
||||
|
||||
// Request events emitted:
|
||||
// 'success' : Request successful.
|
||||
// 'error' : Request failed.
|
||||
@@ -461,12 +463,12 @@ Remote.prototype._connect_message = function (ws, json) {
|
||||
unexpected = true;
|
||||
}
|
||||
else if ('success' === message.status) {
|
||||
if (this.trace) console.log("remote: response: %s", JSON.stringify(message, undefined, 2));
|
||||
if (this.trace) utils.logObject("remote: response: %s", message);
|
||||
|
||||
request.emit('success', message.result);
|
||||
}
|
||||
else if (message.error) {
|
||||
if (this.trace) console.log("remote: error: %s", JSON.stringify(message, undefined, 2));
|
||||
if (this.trace) utils.logObject("remote: error: %s", message);
|
||||
|
||||
request.emit('error', {
|
||||
'error' : 'remoteError',
|
||||
@@ -492,7 +494,7 @@ Remote.prototype._connect_message = function (ws, json) {
|
||||
|
||||
// Account subscription event
|
||||
case 'account':
|
||||
if (this.trace) console.log("remote: account: %s", JSON.stringify(message, undefined, 2));
|
||||
if (this.trace) utils.logObject("remote: account: %s", message);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -536,12 +538,12 @@ Remote.prototype.request = function (request) {
|
||||
|
||||
this.id += 1; // Advance id.
|
||||
|
||||
if (this.trace) console.log("remote: request: %s", JSON.stringify(request.message));
|
||||
if (this.trace) utils.logObject("remote: request: %s", request.message);
|
||||
|
||||
this.ws.send(JSON.stringify(request.message));
|
||||
}
|
||||
else {
|
||||
if (this.trace) console.log("remote: request: DROPPING: %s", JSON.stringify(request.message));
|
||||
if (this.trace) utils.logObject("remote: request: DROPPING: %s", request.message);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -70,10 +70,16 @@ var stringToArray = function (s) {
|
||||
return a;
|
||||
};
|
||||
|
||||
exports.trace = trace;
|
||||
exports.arraySet = arraySet;
|
||||
exports.hexToString = hexToString;
|
||||
var logObject = function (msg, obj) {
|
||||
console.log(msg, JSON.stringify(obj, undefined, 2));
|
||||
};
|
||||
|
||||
|
||||
exports.trace = trace;
|
||||
exports.arraySet = arraySet;
|
||||
exports.hexToString = hexToString;
|
||||
exports.stringToArray = stringToArray;
|
||||
exports.stringToHex = stringToHex;
|
||||
exports.stringToHex = stringToHex;
|
||||
exports.logObject = logObject;
|
||||
|
||||
// vim:sw=2:sts=2:ts=8:et
|
||||
|
||||
7
src/js/utils.web.js
Normal file
7
src/js/utils.web.js
Normal file
@@ -0,0 +1,7 @@
|
||||
exports = module.exports = require('./utils.js');
|
||||
|
||||
// We override this function for browsers, because they print objects nicer
|
||||
// natively than JSON.stringify can.
|
||||
exports.logObject = function (msg, obj) {
|
||||
console.log(msg, "", obj);
|
||||
};
|
||||
Reference in New Issue
Block a user