diff --git a/common.js b/common.js index f81ab4e0..117e81a7 100644 --- a/common.js +++ b/common.js @@ -1,6 +1,7 @@ var common = {}; common.lnd_server_url = ''; +common.enable_logging = false; common.convertToBTC = (num) => { return (num / 100000000).toFixed(6); diff --git a/connect.js b/connect.js index 7095cf69..1ca3d023 100644 --- a/connect.js +++ b/connect.js @@ -7,6 +7,7 @@ var path = require('path'); var macaroonPath = ''; var options = {}; var file_path = path.normalize(__dirname) + '/RTL.conf'; +var log_file_path = path.normalize(__dirname) + '/RTL.log'; var defaultConfig = { Authentication: { @@ -14,7 +15,8 @@ var defaultConfig = { macroonPath:'', nodeAuthType:'DEFAULT', lndConfigPath:'', - rtlPass:'' + rtlPass:'', + enableLogging: false }, Settings: { flgSidenavOpened:true, @@ -59,6 +61,22 @@ var validateConfigFile = (macaroonPath, config) => { errMsg = errMsg + '\nCustom Node Authentication can be set with RTL password only. Please set RTL Password in RTL.conf'; } + if(undefined !== config.Authentication.enableLogging) { + common.enable_logging = config.Authentication.enableLogging; + let exists = fs.existsSync(log_file_path); + if(exists) { + fs.writeFile(log_file_path, ''); + } else if (!exists && config.Authentication.enableLogging) { + try { + var createStream = fs.createWriteStream(log_file_path); + createStream.end(); + } + catch(err) { + console.error('Something went wrong, unable to create log file!' + err); + } + } + } + if(errMsg !== '') { throw new Error(errMsg); } diff --git a/controllers/RTLConf.js b/controllers/RTLConf.js index a9dc50e9..38e704fe 100644 --- a/controllers/RTLConf.js +++ b/controllers/RTLConf.js @@ -2,19 +2,19 @@ var ini = require('ini'); var path = require('path'); var fs = require('fs'); var file_path = path.normalize(__dirname + '/..') + '/RTL.conf'; +var logger = require('./logger'); exports.getUISettings = (req, res, next) => { - console.log('Getting UI Settings!'); + logger.info('\r\nConf: 7: ' + JSON.stringify(Date.now()) + ': INFO: Getting UI Settings'); fs.readFile(file_path, 'utf8', function(err, data) { if (err) { - console.log('Reading UI Settings Failed!'); + logger.error('\r\nConf: 10: ' + JSON.stringify(Date.now()) + ': ERROR: Getting UI Settings Failed!'); res.status(500).json({ message: "Reading UI Settings Failed!", error: err }); } else { const jsonConfig = ini.parse(data); - console.log('UI settings read successfully'); res.status(200).json({settings: jsonConfig.Settings}); } }); @@ -26,30 +26,28 @@ exports.updateUISettings = (req, res, next) => { fs.writeFileSync(file_path, ini.stringify(config)); fs.appendFile(file_path, ini.stringify(req.body.updatedSettings, { section: 'Settings' }), function(err) { if (err) { - console.log('Updating UI Settings Failed!'); + logger.error('\r\nConf: 28: ' + JSON.stringify(Date.now()) + ': ERROR: Updating UI Settings Failed!'); res.status(500).json({ message: "Updating UI Settings Failed!", error: 'Updating UI Settings Failed!' }); } else { - console.log('UI Settings Updated Successfully'); + logger.info('\r\nConf: 34: ' + JSON.stringify(Date.now()) + ': INFO: Updating UI Settings Succesful!'); res.status(201).json({message: 'UI Settings Updated Successfully'}); } }); }; exports.getLNDConfig = (req, res, next) => { - console.log('Getting LND Conf Settings!'); fs.readFile(req.headers.filepath, 'utf8', function(err, data) { if (err) { - console.log('Reading Config File Failed!'); + logger.error('\r\nConf: 43: ' + JSON.stringify(Date.now()) + ': ERROR: Reading Conf Failed!'); res.status(500).json({ message: "Reading Config File Failed!", error: err }); } else { const jsonConfig = ini.parse(data); - console.log('LND Conf read successfully'); if (undefined !== jsonConfig.Bitcoind && undefined !== jsonConfig.Bitcoind['bitcoind.rpcpass']) { jsonConfig.Bitcoind['bitcoind.rpcpass'] = jsonConfig.Bitcoind['bitcoind.rpcpass'].replace(/./g, '*'); } diff --git a/controllers/authenticate.js b/controllers/authenticate.js index 8c933473..6f826269 100644 --- a/controllers/authenticate.js +++ b/controllers/authenticate.js @@ -5,12 +5,13 @@ var rtl_config_path = path.normalize(__dirname + '/..') + '/RTL.conf'; const jwt = require("jsonwebtoken"); var upperCase = require('upper-case'); var atob = require('atob'); +var logger = require('./logger'); exports.authenticateUser = (req, res, next) => { password = atob(req.body.password); fs.readFile(rtl_config_path, 'utf8', function (err, data) { if (err) { - console.log('RTL Config Reading Failed!'); + logger.error('\r\nAuthenticate: 13: ' + JSON.stringify(Date.now()) + ': ERROR: RTL Config Reading Failed!'); res.status(500).json({ message: "RTL Config Reading Failed!", error: err @@ -42,7 +43,7 @@ exports.authenticateUser = (req, res, next) => { } else { fs.readFile(lndConfigPath, 'utf8', function (err, data) { if (err) { - console.log('LND Config Reading Failed!'); + logger.error('\r\nAuthenticate: 45: ' + JSON.stringify(Date.now()) + ': ERROR: RTL Config Reading Failed!'); res.status(500).json({ message: "LND Config Reading Failed!", error: err diff --git a/controllers/balance.js b/controllers/balance.js index 1fee7e95..96ac6e24 100644 --- a/controllers/balance.js +++ b/controllers/balance.js @@ -1,12 +1,13 @@ var request = require('request-promise'); var options = require("../connect"); var common = require('../common'); +var logger = require('./logger'); exports.getBalance = (req, res, next) => { options.url = common.lnd_server_url + '/balance/' + req.params.source; options.qs = req.query; request(options).then((body) => { - console.log('Request params: ' + JSON.stringify(req.params) + '\nRequest Query: ' + JSON.stringify(req.query) + ' \nBalance Received: ' + JSON.stringify(body)); + logger.info('\r\nBalance: 9: ' + JSON.stringify(Date.now()) + ': INFO: ' + 'Request params: ' + JSON.stringify(req.params) + 'Request Query: ' + JSON.stringify(req.query) + ' Balance Received: ' + JSON.stringify(body)); if(undefined !== body) { body.btc_balance = (undefined === body.balance) ? 0 : common.convertToBTC(body.balance); body.btc_total_balance = (undefined === body.total_balance) ? 0 : common.convertToBTC(body.total_balance); diff --git a/controllers/channels.js b/controllers/channels.js index 45aee3ff..8faca260 100644 --- a/controllers/channels.js +++ b/controllers/channels.js @@ -1,19 +1,17 @@ var request = require('request-promise'); var options = require('../connect'); var common = require('../common'); +var logger = require('./logger'); getAliasForChannel = (channel, channelType) => { - console.log('CHANNEL: '); - console.log(channel); return new Promise(function(resolve, reject) { if (undefined === channelType || channelType === 'all') { options.url = common.lnd_server_url + '/graph/node/' + channel.remote_pubkey; } else { options.url = common.lnd_server_url + '/graph/node/' + channel.channel.remote_node_pub; } - console.log('URL: ' + options.url); request(options).then(function(aliasBody) { - console.log('Alias: ' + JSON.stringify(aliasBody.node.alias)); + logger.info('\r\nChannels: 13: ' + JSON.stringify(Date.now()) + ': INFO: Alias: ' + JSON.stringify(aliasBody.node.alias)); if (undefined === channelType || channelType === 'all') { channel.remote_alias = aliasBody.node.alias; resolve(aliasBody.node.alias); @@ -43,7 +41,7 @@ exports.getChannels = (req, res, next) => { }) ) .then(function(values) { - console.log(`\nChannels Fetched with Alias: ${JSON.stringify(body)}`); + logger.info('\r\nChannels: 43: ' + JSON.stringify(Date.now()) + ': INFO: Channels with Alias: ' + JSON.stringify(body)); res.status(200).json(body); }).catch(err => { console.error(err.error); @@ -55,7 +53,7 @@ exports.getChannels = (req, res, next) => { } else { body.btc_total_limbo_balance = common.convertToBTC(body.total_limbo_balance); } - console.log(`\nPending Channels Fetched: ${JSON.stringify(body)}`); + logger.info('\r\nChannels: 55: ' + JSON.stringify(Date.now()) + ': INFO: Pending Channels: ' + JSON.stringify(body)); res.status(200).json(body); } }) @@ -68,15 +66,13 @@ exports.getChannels = (req, res, next) => { }; exports.postChannel = (req, res, next) => { - // setTimeout(()=>{res.status(201).json({message: 'Channel Open!'});}, 5000); options.url = common.lnd_server_url + '/channels'; options.form = JSON.stringify({ node_pubkey_string: req.body.node_pubkey, local_funding_amount: req.body.local_funding_amount }); request.post(options).then((body) => { - console.log('Channel Open Response: '); - console.log(body); + logger.info('\r\nChannels: 74: ' + JSON.stringify(Date.now()) + ': INFO: Channel Open Response: ' + JSON.stringify(body)); if(undefined === body || body.error) { res.status(500).json({ message: 'Open Channel Failed!', @@ -108,10 +104,8 @@ exports.postTransactions = (req, res, next) => { dest_string: req.body.paymentDecoded.destination }); } - console.log('Send Payment Options Form:' + options.form); request.post(options).then((body) => { - console.log('Send Payment Response: '); - console.log(body); + logger.info('\r\nChannels: 107: ' + JSON.stringify(Date.now()) + ': INFO: Send Payment Response: ' + JSON.stringify(body)); if(undefined === body || body.error) { res.status(500).json({ message: 'Send Payment Failed!', @@ -137,11 +131,8 @@ exports.postTransactions = (req, res, next) => { exports.closeChannel = (req, res, next) => { let channelpoint = req.params.channelPoint.replace(':', '/'); options.url = common.lnd_server_url + '/channels/' + channelpoint + '?force=' + req.query.force; - console.log('\nClosing Channel URL: '); - console.log(options.url); request.delete(options).then((body) => { - console.log('\nClose Channel Response: '); - console.log(body); + logger.info('\r\nChannels: 134: ' + JSON.stringify(Date.now()) + ': INFO: Close Channel Response: ' + JSON.stringify(body)); if(undefined === body || body.error) { res.status(500).json({ message: 'Close Channel Failed!', diff --git a/controllers/fees.js b/controllers/fees.js index edc612f6..6af9d92d 100644 --- a/controllers/fees.js +++ b/controllers/fees.js @@ -1,11 +1,12 @@ var request = require('request-promise'); var options = require("../connect"); var common = require('../common'); +var logger = require('./logger'); exports.getFees = (req, res, next) => { options.url = common.lnd_server_url + '/fees'; request(options).then((body) => { - console.log("Fee Received: " + JSON.stringify(body)); + logger.info('\r\nFees: 8: ' + JSON.stringify(Date.now()) + ': INFO: Fee Received: ' + JSON.stringify(body)); if(undefined === body || body.error) { res.status(500).json({ message: "Fetching fee failed!", diff --git a/controllers/getInfo.js b/controllers/getInfo.js index 9aaab014..39ca1004 100644 --- a/controllers/getInfo.js +++ b/controllers/getInfo.js @@ -1,15 +1,14 @@ var request = require('request-promise'); var options = require("../connect"); var common = require('../common'); +var logger = require('./logger'); exports.getInfo = (req, res, next) => { options.url = common.lnd_server_url + '/getinfo'; request(options).then((body) => { - console.log('body'); - console.log(body); + logger.info('\r\nGetInfo: 9: ' + JSON.stringify(Date.now()) + ': INFO: ' + JSON.stringify(body)); const body_str = (undefined === body) ? '' : JSON.stringify(body); const search_idx = (undefined === body) ? -1 : body_str.search('Not Found'); - console.log('Information Received: ' + body_str); if(undefined === body || search_idx > -1 || body.error) { res.status(500).json({ message: "Fetching Info failed!", diff --git a/controllers/graph.js b/controllers/graph.js index 29f35ddd..c8119faa 100644 --- a/controllers/graph.js +++ b/controllers/graph.js @@ -1,13 +1,14 @@ var request = require("request-promise"); var options = require("../connect"); var common = require('../common'); +var logger = require('./logger'); exports.getDescribeGraph = (req, res, next) => { options.url = common.lnd_server_url + '/graph'; request.get(options).then((body) => { const body_str = (undefined === body) ? '' : JSON.stringify(body); const search_idx = (undefined === body) ? -1 : body_str.search('Not Found'); - console.log('Describe Graph Received: ' + body_str); + logger.info('\r\nGraph: 10: ' + JSON.stringify(Date.now()) + ': INFO: Describe Graph Received: ' + body_str); if(undefined === body || search_idx > -1 || body.error) { res.status(500).json({ message: "Fetching Describe Graph Failed!", @@ -30,7 +31,7 @@ exports.getGraphInfo = (req, res, next) => { request.get(options).then((body) => { const body_str = (undefined === body) ? '' : JSON.stringify(body); const search_idx = (undefined === body) ? -1 : body_str.search('Not Found'); - console.log('Network Information Received: ' + body_str); + logger.info('\r\nGraph: 33: ' + JSON.stringify(Date.now()) + ': INFO: Network Info Received: ' + body_str); if(undefined === body || search_idx > -1 || body.error) { res.status(500).json({ message: "Fetching network Info failed!", @@ -41,7 +42,7 @@ exports.getGraphInfo = (req, res, next) => { body.btc_avg_channel_size = (undefined === body.avg_channel_size) ? 0 : common.convertToBTC(body.avg_channel_size); body.btc_min_channel_size = (undefined === body.min_channel_size) ? 0 : common.convertToBTC(body.min_channel_size); body.btc_max_channel_size = (undefined === body.max_channel_size) ? 0 : common.convertToBTC(body.max_channel_size); - console.log('Network Information After Rounding and Conversion: ' + body_str); + logger.info('\r\nGraph: 44: ' + JSON.stringify(Date.now()) + ': INFO: Network Information After Rounding and Conversion: ' + body_str); res.status(200).json(body); } }) @@ -55,9 +56,8 @@ exports.getGraphInfo = (req, res, next) => { exports.getGraphNode = (req, res, next) => { options.url = common.lnd_server_url + '/graph/node/' + req.params.pubKey; - console.log(`Node Information url: ` + options.url); request(options).then((body) => { - console.log(`Node Information Received: ${JSON.stringify(body)}`); + logger.info('\r\nGraph: 59: ' + JSON.stringify(Date.now()) + ': INFO: Node Info Received: ' + JSON.stringify(body)); if(undefined === body || body.error) { res.status(500).json({ message: "Fetching node Info failed!", @@ -76,9 +76,8 @@ exports.getGraphNode = (req, res, next) => { exports.getGraphEdge = (req, res, next) => { options.url = common.lnd_server_url + '/graph/edge/' + req.params.chanid; - console.log(`Edge Information url: ` + options.url); request(options).then((body) => { - console.log(`Edge Information Received: ${JSON.stringify(body)}`); + logger.info('\r\nGraph: 79: ' + JSON.stringify(Date.now()) + ': INFO: Edge Info Received: ' + JSON.stringify(body)); if(undefined === body || body.error) { res.status(500).json({ message: "Fetching Edge Info Failed!", diff --git a/controllers/invoices.js b/controllers/invoices.js index cf5ba89c..17e4de67 100644 --- a/controllers/invoices.js +++ b/controllers/invoices.js @@ -1,11 +1,12 @@ var request = require('request-promise'); var options = require("../connect"); var common = require('../common'); +var logger = require('./logger'); exports.getInvoice = (req, res, next) => { options.url = common.lnd_server_url + '/invoice/' + req.params.rHashStr; request(options).then((body) => { - console.log(`Invoice Information Received: ${JSON.stringify(body)}`); + logger.info('\r\nInvoice: 8: ' + JSON.stringify(Date.now()) + ': INFO: Invoice Info Received: ' + JSON.stringify(body)); if(undefined === body || body.error) { res.status(500).json({ message: "Fetching Invoice Info Failed!", @@ -27,7 +28,7 @@ exports.listInvoices = (req, res, next) => { request(options).then((body) => { const body_str = (undefined === body) ? '' : JSON.stringify(body); const search_idx = (undefined === body) ? -1 : body_str.search('Not Found'); - console.log('Information Received: ' + body_str); + logger.info('\r\nInvoice: 30: ' + JSON.stringify(Date.now()) + ': INFO: Invoices List Received: ' + body_str); if(undefined === body || search_idx > -1 || body.error) { res.status(500).json({ message: "Fetching Invoice Info failed!", @@ -42,7 +43,7 @@ exports.listInvoices = (req, res, next) => { invoice.btc_amt_paid_sat = (undefined === invoice.amt_paid_sat) ? 0 : common.convertToBTC(invoice.amt_paid_sat); }); } - console.log('\nInvoices Received: ' + JSON.stringify(body)); + logger.info('\r\nInvoice: 45: ' + JSON.stringify(Date.now()) + ': INFO: Invoices List Received: ' + JSON.stringify(body)); res.status(200).json(body); } }) @@ -60,10 +61,8 @@ exports.addInvoice = (req, res, next) => { memo: req.body.memo, value: req.body.amount }); - console.log('Add Invoice Options Form:' + options.form); request.post(options).then((body) => { - console.log('Add Invoice Response: '); - console.log(body); + logger.info('\r\nInvoice: 64: ' + JSON.stringify(Date.now()) + ': INFO: Add Invoice Responce: ' + JSON.stringify(body)); if(undefined === body || body.error) { res.status(500).json({ message: "Add Invoice Failed!", diff --git a/controllers/logger.js b/controllers/logger.js new file mode 100644 index 00000000..cfdf0ec2 --- /dev/null +++ b/controllers/logger.js @@ -0,0 +1,30 @@ +var fs = require('fs'); +var path = require('path'); +var file_path = path.normalize(__dirname + '/..') + '/RTL.log'; +var common = require('../common'); + +exports.info = (msgStr) => { + console.log('Console: ' + msgStr); + if(common.enable_logging) { + fs.appendFile(file_path, msgStr, function(err) { + if (err) { + return ({ error: 'Updating Log Failed!' }); + } else { + return ({ message: 'Log Updated Successfully' }); + } + }); + } +} + +exports.error = (msgStr) => { + console.error('Console: ' + msgStr); + if(common.enable_logging) { + fs.appendFile(file_path, msgStr, function(err) { + if (err) { + return ({ error: 'Updating Log Failed!' }); + } else { + return ({ message: 'Log Updated Successfully' }); + } + }); + } +} \ No newline at end of file diff --git a/controllers/newAddress.js b/controllers/newAddress.js index 188051ec..4373cfd7 100644 --- a/controllers/newAddress.js +++ b/controllers/newAddress.js @@ -1,15 +1,14 @@ var request = require('request-promise'); var options = require("../connect"); var common = require('../common'); +var logger = require('./logger'); exports.getNewAddress = (req, res, next) => { options.url = common.lnd_server_url + '/newaddress?type=' + req.query.type; - console.log('Request Query Params: ' + JSON.stringify(req.query)); - console.log('Options URL: ' + JSON.stringify(options.url)); request(options).then((body) => { const body_str = (undefined === body) ? '' : JSON.stringify(body); const search_idx = (undefined === body) ? -1 : body_str.search('Not Found'); - console.log("New Address Received: " + body_str); + logger.info('\r\nNewAddress: 10: ' + JSON.stringify(Date.now()) + ': INFO: New Address Received: ' + body_str); if(undefined === body || search_idx > -1 || body.error) { res.status(500).json({ message: "Fetching new address failed!", diff --git a/controllers/payReq.js b/controllers/payReq.js index 616a78cc..7c27b0b7 100644 --- a/controllers/payReq.js +++ b/controllers/payReq.js @@ -1,14 +1,14 @@ var request = require('request-promise'); var options = require("../connect"); var common = require('../common'); +var logger = require('./logger'); exports.decodePayment = (req, res, next) => { options.url = common.lnd_server_url + '/payreq/' + req.params.payRequest; - console.log('Options URL: ' + JSON.stringify(options.url)); request(options).then((body) => { const body_str = (undefined === body) ? '' : JSON.stringify(body); const search_idx = (undefined === body) ? -1 : body_str.search('Not Found'); - console.log("Payment Request Decoded Received: " + body_str); + logger.info('\r\nPayReq: 10: ' + JSON.stringify(Date.now()) + ': INFO: Payment Decodd Received: ' + body_str); if(undefined === body || search_idx > -1 || body.error) { res.status(500).json({ message: "Payment Request Decode Failed!", diff --git a/controllers/payments.js b/controllers/payments.js index 2a0ebfc8..6d7afe89 100644 --- a/controllers/payments.js +++ b/controllers/payments.js @@ -1,13 +1,14 @@ var request = require('request-promise'); var options = require("../connect"); var common = require('../common'); +var logger = require('./logger'); exports.getPayments = (req, res, next) => { options.url = common.lnd_server_url + '/payments'; request(options).then((body) => { const body_str = (undefined === body) ? '' : JSON.stringify(body); const search_idx = (undefined === body) ? -1 : body_str.search('Not Found'); - console.log("Payment Request Decoded Received: " + body_str); + logger.info('\r\nPayments: 10: ' + JSON.stringify(Date.now()) + ': INFO: Payment Decoded Received: ' + body_str); if(undefined === body || search_idx > -1 || body.error) { res.status(500).json({ message: "Payments List Failed!", diff --git a/controllers/peers.js b/controllers/peers.js index 9ca88aa5..58485276 100644 --- a/controllers/peers.js +++ b/controllers/peers.js @@ -2,13 +2,14 @@ var fs = require('fs'); var request = require('request-promise'); var options = require("../connect"); var common = require('../common'); +var logger = require('./logger'); getAliasForPeers = (peer) => { return new Promise(function(resolve, reject) { options.url = common.lnd_server_url + '/graph/node/' + peer.pub_key; request(options) .then(function(aliasBody) { - console.log('Alias: ' + JSON.stringify(aliasBody.node.alias)); + logger.info('\r\nPeers: 11: ' + JSON.stringify(Date.now()) + ': INFO: Alias: ' + JSON.stringify(aliasBody.node.alias)); peer.alias = aliasBody.node.alias; resolve(aliasBody.node.alias); }) @@ -26,7 +27,7 @@ exports.getPeers = (req, res, next) => return getAliasForPeers(peer); })) .then(function(values) { - console.log(`\nPeers Fetched with Alias: ${JSON.stringify(body)}`); + logger.info('\r\nPeers: 29: ' + JSON.stringify(Date.now()) + ': INFO: Peers with Alias: ' + JSON.stringify(body)); res.status(200).json(body.peers); }); }) @@ -44,10 +45,8 @@ exports.postPeer = (req, res, next) => { addr: { host: req.body.host, pubkey: req.body.pubkey }, perm: req.body.perm }); - console.log('Options: ' + JSON.stringify(options)); request.post(options, (error, response, body) => { - console.log('Peer Add Response: '); - console.log(body); + logger.info('\r\nPeers: 48: ' + JSON.stringify(Date.now()) + ': INFO: Peer Added: ' + JSON.stringify(body)); if(undefined === body || body.error) { res.status(500).json({ message: "Adding peer failed!", @@ -62,8 +61,8 @@ exports.postPeer = (req, res, next) => { return getAliasForPeers(peer); })) .then(function(values) { - console.log(`\nPeer Added Succesfully!`); - console.log(`\nPeers Fetched with Alias: ${JSON.stringify(body)}`); + logger.info('\r\nPeers: 63: ' + JSON.stringify(Date.now()) + ': INFO: Peer Added Successfully'); + logger.info('\r\nPeers: 64: ' + JSON.stringify(Date.now()) + ': INFO: Peer with Alias: ' + JSON.stringify(body)); res.status(201).json(body.peers); }) .catch((err) => { @@ -79,18 +78,15 @@ exports.postPeer = (req, res, next) => { exports.deletePeer = (req, res, next) => { options.url = common.lnd_server_url + '/peers/' + req.params.peerPubKey; - console.log('Detach Peer Options: '); - console.log(options.url); request.delete(options).then((body) => { - console.log('Detach Peer Response: '); - console.log(body); + logger.info('\r\nPeers: 81: ' + JSON.stringify(Date.now()) + ': INFO: Detach Peer Response: ' + JSON.stringify(body)); if(undefined === body || body.error) { res.status(500).json({ message: "Detach peer failed!", error: (undefined === body) ? 'Error From Server!' : body.error }); } else { - console.log('\nPeer Detached: ' + req.params.peerPubKey); + logger.info('\r\nPeers: 88: ' + JSON.stringify(Date.now()) + ': INFO: Peer Detached: ' + req.params.peerPubKey); res.status(204).json({}); } }) diff --git a/controllers/transactions.js b/controllers/transactions.js index aa4ebac6..b3cd53ae 100644 --- a/controllers/transactions.js +++ b/controllers/transactions.js @@ -1,13 +1,14 @@ var request = require('request-promise'); var options = require("../connect"); var common = require('../common'); +var logger = require('./logger'); exports.getTransactions = (req, res, next) => { options.url = common.lnd_server_url + '/transactions'; request(options).then((body) => { const body_str = (undefined === body) ? '' : JSON.stringify(body); const search_idx = (undefined === body) ? -1 : body_str.search('Not Found'); - console.log('Transactions Received: ' + body_str); + logger.info('\r\nTransactions: 10: ' + JSON.stringify(Date.now()) + ': INFO: Transaction Received: ' + body_str); if(undefined === body || search_idx > -1 || body.error) { res.status(500).json({ message: "Fetching Transactions Failed!", @@ -39,8 +40,7 @@ exports.postTransactions = (req, res, next) => { target_conf: req.body.blocks }); request.post(options).then((body) => { - console.log('Transactions Post Response: '); - console.log(body); + logger.info('\r\nTransactions: 42: ' + JSON.stringify(Date.now()) + ': INFO: Transaction Post Response: ' + JSON.stringify(body)); if(undefined === body || body.error) { res.status(500).json({ message: "Transactions post failed!", diff --git a/controllers/wallet.js b/controllers/wallet.js index 17432bee..8439ad04 100644 --- a/controllers/wallet.js +++ b/controllers/wallet.js @@ -1,6 +1,7 @@ var request = require('request-promise'); var options = require("../connect"); var common = require('../common'); +var logger = require('./logger'); exports.operateWallet = (req, res, next) => { var requestBody = { @@ -17,8 +18,7 @@ exports.operateWallet = (req, res, next) => { } options.qs = req.query; request.post(options).then((body) => { - console.log('\nUnlock Wallet Response: '); - console.log(body); + logger.info('\r\nWallet: 20: ' + JSON.stringify(Date.now()) + ': INFO: Unlock Wallet Response: ' + JSON.stringify(body)); const body_str = (undefined === body) ? '' : JSON.stringify(body); const search_idx = (undefined === body) ? -1 : body_str.search('Not Found'); if(undefined === body) { diff --git a/package-lock.json b/package-lock.json index c504924d..273fbb38 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "rtl", - "version": "0.1.9-alpha", + "version": "0.1.12-alpha", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/sample-RTL.conf b/sample-RTL.conf index b4391da3..f6a974f8 100644 --- a/sample-RTL.conf +++ b/sample-RTL.conf @@ -4,6 +4,7 @@ macroonPath= nodeAuthType= lndConfigPath= rtlPass= +enableLogging=false [Settings] flgSidenavOpened=true flgSidenavPinned=true