From 95450c7be1a878936ba2fa7418e5d942733278df Mon Sep 17 00:00:00 2001 From: Olivier Beddows Date: Tue, 9 Feb 2016 19:16:26 +0000 Subject: [PATCH] Revising log messages. --- app.js | 14 +++++++------- modules/blocks.js | 10 +++++----- modules/dapps.js | 16 ++++++++-------- modules/delegates.js | 18 +++++++++--------- modules/loader.js | 38 +++++++++++++++++++------------------- modules/peer.js | 4 ++-- modules/transport.js | 13 ++++++------- test/variables.js | 2 +- 8 files changed, 57 insertions(+), 58 deletions(-) diff --git a/app.js b/app.js index fb7a31bf1c6..86164f96867 100644 --- a/app.js +++ b/app.js @@ -64,7 +64,7 @@ if (program.log) { process.on('uncaughtException', function (err) { // handle the error safely - logger.fatal('system error', {message: err.message, stack: err.stack}); + logger.fatal('System error', { message: err.message, stack: err.stack }); process.emit('cleanup'); }); @@ -95,7 +95,7 @@ var logger = new Logger({echo: appConfig.consoleLogLevel, errorLevel: appConfig. var d = require('domain').create(); d.on('error', function (err) { - logger.fatal('domain master', {message: err.message, stack: err.stack}); + logger.fatal('Domain master', { message: err.message, stack: err.stack }); process.exit(0); }); d.run(function () { @@ -243,7 +243,7 @@ d.run(function () { dbSequence: ["logger", function (cb, scope) { var sequence = new Sequence({ onWarning: function (current, limit) { - scope.logger.warn("db queue", current) + scope.logger.warn("DB queue", current) } }); cb(null, sequence); @@ -252,7 +252,7 @@ d.run(function () { sequence: ["logger", function (cb, scope) { var sequence = new Sequence({ onWarning: function (current, limit) { - scope.logger.warn("main queue", current) + scope.logger.warn("Main queue", current) } }); cb(null, sequence); @@ -261,7 +261,7 @@ d.run(function () { balancesSequence: ["logger", function (cb, scope) { var sequence = new Sequence({ onWarning: function (current, limit) { - scope.logger.warn("balance queue", current) + scope.logger.warn("Balance queue", current) } }); cb(null, sequence); @@ -415,11 +415,11 @@ d.run(function () { var d = require('domain').create(); d.on('error', function (err) { - scope.logger.fatal('domain ' + name, {message: err.message, stack: err.stack}); + scope.logger.fatal('Domain ' + name, {message: err.message, stack: err.stack}); }); d.run(function () { - logger.debug('loading module', name) + logger.debug('Loading module', name) var Klass = require(config.modules[name]); var obj = new Klass(cb, scope) modules.push(obj); diff --git a/modules/blocks.js b/modules/blocks.js index 5c91c2ccaf3..9ace5b477c2 100644 --- a/modules/blocks.js +++ b/modules/blocks.js @@ -991,12 +991,12 @@ Blocks.prototype.processBlock = function (block, broadcast, cb) { async.eachSeries(block.transactions, function (transaction, cb) { modules.accounts.setAccountAndGet({publicKey: transaction.senderPublicKey}, function (err, sender) { if (err) { - library.logger.error("Can't apply transactions: " + transaction.id); + library.logger.error("Failed to apply transactions: " + transaction.id); process.exit(0); } modules.transactions.apply(transaction, block, sender, function (err) { if (err) { - library.logger.error("Can't apply transactions: " + transaction.id); + library.logger.error("Failed to apply transactions: " + transaction.id); process.exit(0); } modules.transactions.removeUnconfirmedTransaction(transaction.id); @@ -1006,7 +1006,7 @@ Blocks.prototype.processBlock = function (block, broadcast, cb) { }, function (err) { private.saveBlock(block, function (err) { if (err) { - library.logger.error("Can't save block..."); + library.logger.error("Failed to save block..."); library.logger.error(err); process.exit(0); } @@ -1075,7 +1075,7 @@ Blocks.prototype.loadBlocksFromPeer = function (peer, lastCommonBlockId, cb) { block = library.logic.block.objectNormalize(block); } catch (e) { var peerStr = data.peer ? ip.fromLong(data.peer.ip) + ":" + data.peer.port : 'unknown'; - library.logger.log('block ' + (block ? block.id : 'null') + ' is not valid, ban 60 min', peerStr); + library.logger.log('Block ' + (block ? block.id : 'null') + ' is not valid, ban 60 min', peerStr); modules.peer.state(peer.ip, peer.port, 0, 3600); return setImmediate(cb, e); } @@ -1085,7 +1085,7 @@ Blocks.prototype.loadBlocksFromPeer = function (peer, lastCommonBlockId, cb) { lastValidBlock = block; } else { var peerStr = data.peer ? ip.fromLong(data.peer.ip) + ":" + data.peer.port : 'unknown'; - library.logger.log('block ' + (block ? block.id : 'null') + ' is not valid, ban 60 min', peerStr); + library.logger.log('Block ' + (block ? block.id : 'null') + ' is not valid, ban 60 min', peerStr); modules.peer.state(peer.ip, peer.port, 0, 3600); } diff --git a/modules/dapps.js b/modules/dapps.js index 66b14e71ad3..cb3265ef498 100644 --- a/modules/dapps.js +++ b/modules/dapps.js @@ -1736,7 +1736,7 @@ private.removeDApp = function (dApp, cb) { function remove(err) { if (err) { - library.logger.error("Uninstall dapp: " + err); + library.logger.error("Failed to uninstall dapp: " + err); } rmdir(dappPath, function (err) { @@ -1760,7 +1760,7 @@ private.removeDApp = function (dApp, cb) { modules.sql.dropTables(dApp.transactionId, blockchain, function (err) { if (err) { - library.logger.error("Can't remove tables of dapp: " + err); + library.logger.error("Failed to drop dapp tables: " + err); } remove(err); }); @@ -1813,7 +1813,7 @@ private.downloadDApp = function (dApp, cb) { // Fetch from sia modules.sia.uploadAscii(dApp.siaAscii, function (err, file) { if (err) { - library.logger.error("Uploading ascii: " + err.toString()); + library.logger.error("Failed to upload ascii: " + err.toString()); rmdir(dappPath, function (err) { if (err) { library.logger.error(err.toString()); @@ -2160,19 +2160,19 @@ private.launchApp = function (dApp, params, cb) { private.sandboxes[dApp.transactionId] = sandbox; sandbox.on("exit", function () { - library.logger.info("DApp " + dApp.transactionId + " closed "); + library.logger.info("Dapp " + dApp.transactionId + " closed "); private.stop(dApp, function (err) { if (err) { - library.logger.error("Error on stop dapp: " + err); + library.logger.error("Encountered error while stopping dapp: " + err); } }); }); sandbox.on("error", function (err) { - library.logger.info("Error in DApp " + dApp.transactionId + " " + err.toString()); + library.logger.info("Encountered error in dapp " + dApp.transactionId + " " + err.toString()); private.stop(dApp, function (err) { if (err) { - library.logger.error("Error on stop dapp: " + err); + library.logger.error("Encountered error while stopping dapp: " + err); } }); }); @@ -2408,7 +2408,7 @@ DApps.prototype.onBlockchainReady = function () { id: dapp.dappid, master: library.config.dapp.masterpassword }, function (err) { - console.log("launched " + dapp.dappid, err || "successfully") + console.log("Launched " + dapp.dappid, err || "successfully") cb(); }); }); diff --git a/modules/delegates.js b/modules/delegates.js index 85988115faf..272c1d0f723 100644 --- a/modules/delegates.js +++ b/modules/delegates.js @@ -490,12 +490,12 @@ private.getBlockSlotData = function (slot, height, cb) { private.loop = function (cb) { if (!Object.keys(private.keypairs).length) { - library.logger.debug('loop', 'exit: have no delegates'); + library.logger.debug('Loop', 'exit: no delegates'); return setImmediate(cb); } if (!private.loaded || modules.loader.syncing() || !modules.round.loaded()) { - // library.logger.log('loop', 'exit: syncing'); + // library.logger.log('Loop', 'exit: syncing'); return setImmediate(cb); } @@ -503,13 +503,13 @@ private.loop = function (cb) { var lastBlock = modules.blocks.getLastBlock(); if (currentSlot == slots.getSlotNumber(lastBlock.timestamp)) { - // library.logger.log('loop', 'exit: lastBlock is in the same slot'); + // library.logger.log('Loop', 'exit: lastBlock is in the same slot'); return setImmediate(cb); } private.getBlockSlotData(currentSlot, lastBlock.height + 1, function (err, currentBlockData) { if (err || currentBlockData === null) { - library.logger.log('loop', 'skip slot'); + library.logger.log('Loop', 'skiping slot'); return setImmediate(cb); } @@ -520,12 +520,12 @@ private.loop = function (cb) { cb(err); }); } else { - // library.logger.log('loop', 'exit: ' + _activeDelegates[slots.getSlotNumber() % slots.delegates] + ' delegate slot'); + // library.logger.log('Loop', 'exit: ' + _activeDelegates[slots.getSlotNumber() % slots.delegates] + ' delegate slot'); setImmediate(cb); } }, function (err) { if (err) { - library.logger.error("Problem in block generation", err); + library.logger.error("Failed to get block slot data", err); } setImmediate(cb); }); @@ -556,7 +556,7 @@ private.loadMyDelegates = function (cb) { private.keypairs[keypair.publicKey.toString('hex')] = keypair; library.logger.info("Forging enabled on account: " + account.address); } else { - library.logger.info("Forger with this public key not found " + keypair.publicKey.toString('hex')); + library.logger.info("Delegate with this public key not found: " + keypair.publicKey.toString('hex')); } cb(); }); @@ -689,7 +689,7 @@ Delegates.prototype.checkUnconfirmedDelegates = function (publicKey, votes, cb) } Delegates.prototype.fork = function (block, cause) { - library.logger.info('fork', { + library.logger.info('Fork', { delegate: block.generatorPublicKey, block: {id: block.id, timestamp: block.timestamp, height: block.height, previousBlock: block.previousBlock}, cause: cause @@ -737,7 +737,7 @@ Delegates.prototype.onBlockchainReady = function () { private.loadMyDelegates(function nextLoop(err) { if (err) { - library.logger.error("Can`t load delegates", err); + library.logger.error("Failed to load delegates", err); } private.loop(function () { diff --git a/modules/loader.js b/modules/loader.js index a03cac73f00..90f6540f615 100644 --- a/modules/loader.js +++ b/modules/loader.js @@ -67,7 +67,7 @@ private.loadFullDb = function (peer, cb) { var commonBlockId = private.genesisBlock.block.id; - library.logger.debug("Load blocks from genesis from " + peerStr); + library.logger.debug("Loading blocks from genesis from " + peerStr); modules.blocks.loadBlocksFromPeer(peer, commonBlockId, cb); } @@ -124,13 +124,13 @@ private.findUpdate = function (lastBlock, peer, cb) { } }, function (cb) { - library.logger.debug("Load blocks from peer " + peerStr); + library.logger.debug("Loading blocks from peer " + peerStr); modules.blocks.loadBlocksFromPeer(peer, commonBlock.id, function (err, lastValidBlock) { if (err) { modules.transactions.deleteHiddenTransaction(); library.logger.error(err); - library.logger.log("can't load blocks, ban 60 min", peerStr); + library.logger.log("Failed to load blocks, ban 60 min", peerStr); modules.peer.state(peer.ip, peer.port, 0, 3600); if (lastValidBlock) { @@ -229,7 +229,7 @@ private.loadBlocks = function (lastBlock, cb) { }, function (err, data) { var peerStr = data && data.peer ? ip.fromLong(data.peer.ip) + ":" + data.peer.port : 'unknown'; if (err || !data.body) { - library.logger.log("Fail request at " + peerStr); + library.logger.log("Failed to get height from peer: " + peerStr); return cb(); } @@ -248,7 +248,7 @@ private.loadBlocks = function (lastBlock, cb) { }); if (!report) { - library.logger.log("Can't parse blockchain height: " + peerStr + "\n" + library.scheme.getLastError()); + library.logger.log("Failed to parse blockchain height: " + peerStr + "\n" + library.scheme.getLastError()); return cb(); } @@ -337,7 +337,7 @@ private.loadUnconfirmedTransactions = function (cb) { transactions[i] = library.logic.transaction.objectNormalize(transactions[i]); } catch (e) { var peerStr = data.peer ? ip.fromLong(data.peer.ip) + ":" + data.peer.port : 'unknown'; - library.logger.log('transaction ' + (transactions[i] ? transactions[i].id : 'null') + ' is not valid, ban 60 min', peerStr); + library.logger.log('Transaction ' + (transactions[i] ? transactions[i].id : 'null') + ' is not valid, ban 60 min', peerStr); modules.peer.state(data.peer.ip, data.peer.port, 0, 3600); return setImmediate(cb); } @@ -370,7 +370,7 @@ private.loadBlockChain = function () { function () { return count < offset }, function (cb) { - library.logger.info('current ' + offset); + library.logger.info('Current ' + offset); setImmediate(function () { modules.blocks.loadBlocksOffset(limit, offset, verify, function (err, lastBlockOffset) { if (err) { @@ -387,14 +387,14 @@ private.loadBlockChain = function () { if (err) { library.logger.error('loadBlocksOffset', err); if (err.block) { - library.logger.error('blockchain failed at ', err.block.height) + library.logger.error('Blockchain failed at ', err.block.height) modules.blocks.simpleDeleteAfterBlock(err.block.id, function (err, res) { - library.logger.error('blockchain clipped'); + library.logger.error('Blockchain clipped'); library.bus.message('blockchainReady'); }) } } else { - library.logger.info('blockchain ready'); + library.logger.info('Blockchain ready'); library.bus.message('blockchainReady'); } } @@ -418,10 +418,10 @@ private.loadBlockChain = function () { modules.blocks.count(function (err, count) { if (err) { - return library.logger.error('blocks.count', err) + return library.logger.error('Failed to count blocks', err) } - library.logger.info('blocks ' + count); + library.logger.info('Blocks ' + count); // Check if previous loading missed if (reject || verify || count == 1) { @@ -432,26 +432,26 @@ private.loadBlockChain = function () { , function (err, updated) { if (err) { library.logger.error(err); - library.logger.info("Can't load without verifying, clear accounts from database and load"); + library.logger.info("Unable to load without verifying, clearing accounts from database and loading"); load(count); } else { library.dbLite.query("select a.blockId, b.id from mem_accounts a left outer join blocks b on b.id = a.blockId where b.id is null", {}, ['a_blockId', 'b_id'], function (err, rows) { if (err || rows.length > 0) { - library.logger.error(err || "Found missed block, looks like node went down on block processing"); - library.logger.info("Can't load without verifying, clear accounts from database and load"); + library.logger.error(err || "Encountered missing block, looks like node went down during block processing"); + library.logger.info("Unable to load without verifying, clearing accounts from database and loading"); load(count); } else { // Load delegates library.dbLite.query("SELECT lower(hex(publicKey)) FROM mem_accounts WHERE isDelegate=1", ['publicKey'], function (err, delegates) { if (err || delegates.length == 0) { library.logger.error(err || "No delegates, reload database"); - library.logger.info("Can't load without verifying, clear accounts from database and load"); + library.logger.info("Unable to load without verifying, clearing accounts from database and loading"); load(count); } else { modules.blocks.loadBlocksOffset(1, count, verify, function (err, lastBlock) { if (err) { - library.logger.error(err || "Can't load last block"); - library.logger.info("Can't load without verifying, clear accounts from database and load"); + library.logger.error(err || "Unable to load last block"); + library.logger.info("Unable to load without verifying, clearing accounts from database and loading"); load(count); } else { modules.blocks.loadLastBlock(function (err, block) { @@ -459,7 +459,7 @@ private.loadBlockChain = function () { return load(count); } private.lastBlock = block; - library.logger.info('blockchain ready'); + library.logger.info('Blockchain ready'); library.bus.message('blockchainReady'); }); } diff --git a/modules/peer.js b/modules/peer.js index db1cb46b9bf..1b306c594a9 100644 --- a/modules/peer.js +++ b/modules/peer.js @@ -363,9 +363,9 @@ Peer.prototype.onBlockchainReady = function () { err && library.logger.error('updatePeerList', err); library.bus.message('peerReady'); }) - library.logger.info('peer ready, stored ' + count); + library.logger.info('Peers ready, stored ' + count); } else { - library.logger.warn('peer list is empty'); + library.logger.warn('Peers list is empty'); } }); }); diff --git a/modules/transport.js b/modules/transport.js index 9fdb1dde44a..c956195e9ce 100644 --- a/modules/transport.js +++ b/modules/transport.js @@ -37,7 +37,6 @@ private.attachApi = function () { }); router.use(function (req, res, next) { - // console.log("Request for us: " + req.url); var peerIp = req.headers['x-forwarded-for'] || req.connection.remoteAddress; if (peerIp == "127.0.0.1") { @@ -154,7 +153,7 @@ private.attachApi = function () { var peerIp = req.headers['x-forwarded-for'] || req.connection.remoteAddress; var peerStr = peerIp ? peerIp + ":" + (isNaN(parseInt(req.headers['port'])) ? 'unkwnown' : parseInt(req.headers['port'])) : 'unknown'; - library.logger.log('common block request is not valid, ban 60 min', peerStr); + library.logger.log('Invalid common block request, ban 60 min', peerStr); if (report) { modules.peer.state(ip.toLong(peerIp), RequestSanitizer.int(req.headers['port']), 0, 3600); @@ -230,7 +229,7 @@ private.attachApi = function () { } catch (e) { var peerIp = req.headers['x-forwarded-for'] || req.connection.remoteAddress; var peerStr = peerIp ? peerIp + ":" + (isNaN(parseInt(req.headers['port'])) ? 'unkwnown' : parseInt(req.headers['port'])) : 'unknown'; - library.logger.log('block ' + (block ? block.id : 'null') + ' is not valid, ban 60 min', peerStr); + library.logger.log('Block ' + (block ? block.id : 'null') + ' is not valid, ban 60 min', peerStr); if (peerIp && report) { modules.peer.state(ip.toLong(peerIp), parseInt(req.headers['port']), 0, 3600); @@ -326,7 +325,7 @@ private.attachApi = function () { } catch (e) { var peerIp = req.headers['x-forwarded-for'] || req.connection.remoteAddress; var peerStr = peerIp ? peerIp + ":" + (isNaN(req.headers['port']) ? 'unknown' : req.headers['port']) : 'unknown'; - library.logger.log('recieved transaction ' + (transaction ? transaction.id : 'null') + ' is not valid, ban 60 min', peerStr); + library.logger.log('Received transaction ' + (transaction ? transaction.id : 'null') + ' is not valid, ban 60 min', peerStr); if (peerIp && report) { modules.peer.state(ip.toLong(peerIp), req.headers['port'], 0, 3600); @@ -530,7 +529,7 @@ Transport.prototype.getFromPeer = function (peer, options, cb) { return request(req, function (err, response, body) { if (err || response.statusCode != 200) { - library.logger.debug('request', { + library.logger.debug('Request', { url: req.url, statusCode: response ? response.statusCode : 'unknown', err: err @@ -540,14 +539,14 @@ Transport.prototype.getFromPeer = function (peer, options, cb) { if (err && (err.code == "ETIMEDOUT" || err.code == "ESOCKETTIMEDOUT" || err.code == "ECONNREFUSED")) { modules.peer.remove(peer.ip, peer.port, function (err) { if (!err) { - library.logger.info('remove peer ' + req.method + ' ' + req.url) + library.logger.info('Removing peer ' + req.method + ' ' + req.url) } }); } else { if (!options.not_ban) { modules.peer.state(peer.ip, peer.port, 0, 600, function (err) { if (!err) { - library.logger.info('ban 10 min ' + req.method + ' ' + req.url); + library.logger.info('Ban 10 min ' + req.method + ' ' + req.url); } }); } diff --git a/test/variables.js b/test/variables.js index 9e5130f40ab..4a7e0f447d4 100644 --- a/test/variables.js +++ b/test/variables.js @@ -148,7 +148,7 @@ function getHeight(cb) { function onNewBlock(cb) { getHeight(function (err, height) { - console.log("height: " + height); + console.log("Height: " + height); if (err) { return cb(err); } else {