From 45f430bc7e250a48b3d7bb7a895550dd62056828 Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Tue, 18 Jun 2019 20:27:11 -0700 Subject: [PATCH] Removed old logging library --- src/routes/v3/blockchain.js | 12 ++++---- src/routes/v3/control.js | 1 - src/routes/v3/health-check.js | 7 ++++- src/routes/v3/index.js | 15 ---------- src/routes/v3/logging.js | 51 -------------------------------- src/routes/v3/mining.js | 1 - src/routes/v3/rawtransactions.js | 1 - src/routes/v3/slp.js | 5 ++-- src/routes/v3/util.js | 3 +- src/routes/v3/xpub.js | 3 -- 10 files changed, 16 insertions(+), 83 deletions(-) delete mode 100644 src/routes/v3/index.js delete mode 100644 src/routes/v3/logging.js diff --git a/src/routes/v3/blockchain.js b/src/routes/v3/blockchain.js index 65d772d..57ef71b 100644 --- a/src/routes/v3/blockchain.js +++ b/src/routes/v3/blockchain.js @@ -10,7 +10,6 @@ const router = express.Router() const axios = require("axios") const routeUtils = require("./route-utils") -const logger = require("./logging.js") const wlogger = require("../../util/winston-logging") // Used to convert error messages to strings, to safely pass to users. @@ -204,7 +203,7 @@ async function getBlockHeaderBulk(req, res, next) { }) } - logger.debug( + wlogger.debug( `Executing blockchain/getBlockHeaderBulk with these hashes: `, hashes ) @@ -385,7 +384,7 @@ async function getMempoolEntryBulk(req, res, next) { }) } - logger.debug( + wlogger.debug( `Executing blockchain/getMempoolEntry with these txids: `, txids ) @@ -641,7 +640,10 @@ async function getTxOutProofBulk(req, res, next) { } } - logger.debug(`Executing blockchain/getTxOutProof with these txids: `, txids) + wlogger.debug( + `Executing blockchain/getTxOutProof with these txids: `, + txids + ) // Loop through each txid and creates an array of requests to call in parallel const promises = txids.map(async txid => { @@ -826,7 +828,7 @@ async function verifyTxOutProofBulk(req, res, next) { } } - logger.debug( + wlogger.debug( `Executing blockchain/verifyTxOutProof with these proofs: `, proofs ) diff --git a/src/routes/v3/control.js b/src/routes/v3/control.js index a7994c8..a2e97ce 100644 --- a/src/routes/v3/control.js +++ b/src/routes/v3/control.js @@ -4,7 +4,6 @@ const express = require("express") const router = express.Router() const axios = require("axios") -const logger = require("./logging.js") const routeUtils = require("./route-utils") const wlogger = require("../../util/winston-logging") diff --git a/src/routes/v3/health-check.js b/src/routes/v3/health-check.js index 8c05030..45bb1e7 100644 --- a/src/routes/v3/health-check.js +++ b/src/routes/v3/health-check.js @@ -1,3 +1,8 @@ +/* + This health-check API can be used to test the server for aliveness and + readiness. +*/ + "use strict" const express = require("express") @@ -5,7 +10,7 @@ const router = express.Router() /* GET home page. */ router.get("/", (req, res, next) => { - res.json({ status: "winning v2" }) + res.json({ status: true }) }) module.exports = router diff --git a/src/routes/v3/index.js b/src/routes/v3/index.js deleted file mode 100644 index 33c175f..0000000 --- a/src/routes/v3/index.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict" - -const express = require("express") -const router = express.Router() - -/* GET home page. */ -router.get("/", (req, res, next) => { - res.render("swagger-v2") -}) - -router.get("/v2", (req, res, next) => { - res.render("swagger-v2") -}) - -module.exports = router diff --git a/src/routes/v3/logging.js b/src/routes/v3/logging.js deleted file mode 100644 index 07fd9be..0000000 --- a/src/routes/v3/logging.js +++ /dev/null @@ -1,51 +0,0 @@ -/* - A utility library for setting up greylog2 logging. -*/ - -"use strict" - -// This will be uncommented and correct once we have our logging server functioning. -/* -var graylog2 = require("graylog2"); -var logger = new graylog2.graylog({ - servers: [ - { 'host': '127.0.0.1', port: 12201 }, - { 'host': '127.0.0.2', port: 12201 } - ], - hostname: 'server.name', // the name of this host - // (optional, default: os.hostname()) - facility: 'Node.js', // the facility for these log messages - // (optional, default: "Node.js") - bufferSize: 1350 // max UDP packet size, should never exceed the - // MTU of your system (optional, default: 1400) -}); - -logger.on('error', function (error) { - console.error('Error while trying to write to graylog2:', error); -}); -*/ - -// This is just a placeholder function that will be replaced once we get the -// greylog server working. -function log(msg, obj) { - //console.log(msg, obj) -} - -// This is just a placeholder function that will be replaced once we get the -// greylog server working. -function error(msg, obj) { - if (!obj) console.error(msg) - else console.error(msg, obj) -} - -// This is just a placeholder function that will be replaced once we get the -// greylog server working. -function debug(msg, obj) { - //console.log(msg, obj) -} - -module.exports = { - log, - error, - debug -} diff --git a/src/routes/v3/mining.js b/src/routes/v3/mining.js index 243b75a..54398af 100644 --- a/src/routes/v3/mining.js +++ b/src/routes/v3/mining.js @@ -5,7 +5,6 @@ const router = express.Router() const axios = require("axios") const routeUtils = require("./route-utils") -const logger = require("./logging.js") const wlogger = require("../../util/winston-logging") // Used to convert error messages to strings, to safely pass to users. diff --git a/src/routes/v3/rawtransactions.js b/src/routes/v3/rawtransactions.js index 99104c7..7ffed0c 100644 --- a/src/routes/v3/rawtransactions.js +++ b/src/routes/v3/rawtransactions.js @@ -5,7 +5,6 @@ const router = express.Router() const axios = require("axios") const routeUtils = require("./route-utils") -const logger = require("./logging.js") const wlogger = require("../../util/winston-logging") // Used to convert error messages to strings, to safely pass to users. diff --git a/src/routes/v3/slp.js b/src/routes/v3/slp.js index 19483d1..fb13532 100644 --- a/src/routes/v3/slp.js +++ b/src/routes/v3/slp.js @@ -5,7 +5,6 @@ const router = express.Router() const axios = require("axios") const routeUtils = require("./route-utils") -const logger = require("./logging.js") const strftime = require("strftime") const wlogger = require("../../util/winston-logging") @@ -812,7 +811,7 @@ async function validateBulk(req, res, next) { }) } - logger.debug(`Executing slp/validate with these txids: `, txids) + wlogger.debug(`Executing slp/validate with these txids: `, txids) // Validate each txid const validatePromises = txids.map(async txid => { @@ -865,7 +864,7 @@ async function validateSingle(req, res, next) { return res.json({ error: "txid can not be empty" }) } - logger.debug(`Executing slp/validate/:txid with this txid: `, txid) + wlogger.debug(`Executing slp/validate/:txid with this txid: `, txid) // Validate txid // Dev note: must call module.exports to allow stubs in unit tests. diff --git a/src/routes/v3/util.js b/src/routes/v3/util.js index e222d24..892e538 100644 --- a/src/routes/v3/util.js +++ b/src/routes/v3/util.js @@ -5,7 +5,6 @@ const router = express.Router() const axios = require("axios") const routeUtils = require("./route-utils") -const logger = require("./logging.js") const wlogger = require("../../util/winston-logging") const BITBOXJS = require("@chris.troutner/bitbox-js") @@ -122,7 +121,7 @@ async function validateAddressBulk(req, res, next) { } } - logger.debug(`Executing util/validate with these addresses: `, addresses) + wlogger.debug(`Executing util/validate with these addresses: `, addresses) const { BitboxHTTP, diff --git a/src/routes/v3/xpub.js b/src/routes/v3/xpub.js index bd3256e..60d36e9 100644 --- a/src/routes/v3/xpub.js +++ b/src/routes/v3/xpub.js @@ -7,7 +7,6 @@ const express = require("express") const requestUtils = require("./services/requestUtils") const axios = require("axios") -const logger = require("./logging.js") const routeUtils = require("./route-utils") const wlogger = require("../../util/winston-logging") @@ -48,7 +47,6 @@ async function fromXPubSingle(req, res, next) { }) } - logger.debug(`Executing address/fromXPub with this xpub: `, xpub) wlogger.debug(`Executing address/fromXPub with this xpub: `, xpub) const cashAddr = BITBOX.Address.fromXPub(xpub, hdPath) @@ -67,7 +65,6 @@ async function fromXPubSingle(req, res, next) { } // Write out error to error log. - //logger.error(`Error in rawtransactions/decodeRawTransaction: `, err) wlogger.error(`Error in address.ts/fromXPubSingle().`, err) res.status(500)