From c67677ede77eb994cad82240435d01a42c20d2ca Mon Sep 17 00:00:00 2001 From: hatim boufnichel Date: Tue, 20 Jul 2021 20:03:13 +0200 Subject: [PATCH] mostly logs --- services/gunDB/contact-api/jobs/onOrders.js | 11 -------- services/gunDB/contact-api/utils/index.js | 3 +-- services/gunDB/sockets/index.js | 4 ++- src/routes.js | 29 +++++++-------------- 4 files changed, 13 insertions(+), 34 deletions(-) diff --git a/services/gunDB/contact-api/jobs/onOrders.js b/services/gunDB/contact-api/jobs/onOrders.js index 168758e2..7435e2b1 100644 --- a/services/gunDB/contact-api/jobs/onOrders.js +++ b/services/gunDB/contact-api/jobs/onOrders.js @@ -110,19 +110,12 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => { ordersProcessed.add(orderID) - logger.info( - `onOrders() -> processing order: ${orderID} -- ${JSON.stringify( - order - )} -- addr: ${addr}` - ) - const alreadyAnswered = await getUser() .get(Key.ORDER_TO_RESPONSE) .get(orderID) .then() if (alreadyAnswered) { - logger.info('this order is already answered, quitting') return } @@ -209,10 +202,6 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => { private: true } - logger.info( - `onOrders() -> Will now create an invoice : ${JSON.stringify(invoiceReq)}` - ) - const invoice = await _addInvoice(invoiceReq) logger.info( diff --git a/services/gunDB/contact-api/utils/index.js b/services/gunDB/contact-api/utils/index.js index 530588e8..d9cbaf26 100644 --- a/services/gunDB/contact-api/utils/index.js +++ b/services/gunDB/contact-api/utils/index.js @@ -128,8 +128,7 @@ const tryAndWait = async (promGen, shouldRetry = () => false) => { return resolvedValue } } catch (e) { - logger.error(e) - logger.info(JSON.stringify(e)) + console.log(e) if (e.message === Constants.ErrorCode.NOT_AUTH) { throw e } diff --git a/services/gunDB/sockets/index.js b/services/gunDB/sockets/index.js index a1427703..e966fd89 100644 --- a/services/gunDB/sockets/index.js +++ b/services/gunDB/sockets/index.js @@ -246,7 +246,9 @@ const startSocket = socket => { if (isAuthenticated()) { socket.onAny(() => { - GunActions.setLastSeenApp() + GunActions.setLastSeenApp().catch(e => + console.log('error setting last seen app', e) + ) }) } diff --git a/src/routes.js b/src/routes.js index d0b3525c..a907bea5 100644 --- a/src/routes.js +++ b/src/routes.js @@ -74,11 +74,9 @@ module.exports = async ( } const checkHealth = async () => { - logger.info('Getting service status...') let LNDStatus = {} try { const serviceStatus = await getAvailableService() - logger.info('Received status:', serviceStatus) LNDStatus = serviceStatus } catch (e) { LNDStatus = { @@ -88,7 +86,6 @@ module.exports = async ( } try { - logger.info('Getting API status...') const APIHealth = await Http.get( `${usetls ? 'https' : 'http'}://localhost:${serverPort}/ping` ) @@ -97,7 +94,6 @@ module.exports = async ( responseTime: APIHealth.headers['x-response-time'], success: true } - logger.info('Received API status!', APIStatus) return { LNDStatus, APIStatus, @@ -223,7 +219,6 @@ module.exports = async ( app.use((req, res, next) => { const legacyDeviceId = req.headers['x-shockwallet-device-id'] const deviceId = req.headers['encryption-device-id'] - logger.debug('Decrypting route...') try { if ( nonEncryptedRoutes.includes(req.path) || @@ -308,21 +303,12 @@ module.exports = async ( app.use(async (req, res, next) => { const legacyDeviceId = req.headers['x-shockwallet-device-id'] const deviceId = req.headers['encryption-device-id'] - logger.info('Decrypting route...') try { if ( nonEncryptedRoutes.includes(req.path) || process.env.DISABLE_SHOCK_ENCRYPTION === 'true' || (legacyDeviceId && !deviceId) ) { - logger.info( - 'Unprotected route detected! ' + - req.path + - ' Legacy ID:' + - legacyDeviceId + - ' Device ID:' + - deviceId - ) return next() } @@ -371,7 +357,6 @@ module.exports = async ( }) app.use(async (req, res, next) => { - logger.info(`Route: ${req.path}`) if (unprotectedRoutes[req.method][req.path]) { next() } else { @@ -502,7 +487,7 @@ module.exports = async ( */ app.get('/healthz', async (req, res) => { const health = await checkHealth() - logger.info('Healthz response:', health) + logger.info('Healthz response:', health.APIStatus.success) res.json(health) }) @@ -1112,7 +1097,6 @@ module.exports = async ( res.json({ errorMessage: 'LND is down' }) } } - logger.info('GetInfo:', response) if (!response.uris || response.uris.length === 0) { if (config.lndAddress) { response.uris = [response.identity_pubkey + '@' + config.lndAddress] @@ -3163,6 +3147,7 @@ module.exports = async ( ap.get('/api/gun/once/:path', async (req, res) => { const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER) const { path } = req.params + logger.info(`gun ONCE: ${path}`) try { const data = await handleGunFetch({ path, @@ -3189,6 +3174,7 @@ module.exports = async ( ap.get('/api/gun/load/:path', async (req, res) => { const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER) const { path } = req.params + logger.info(`gun LOAD: ${path}`) try { const data = await handleGunFetch({ path, @@ -3215,6 +3201,7 @@ module.exports = async ( ap.get('/api/gun/user/once/:path', async (req, res) => { const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER) const { path } = req.params + logger.info(`gun otheruser ONCE: ${path}`) try { const data = await handleGunFetch({ path, @@ -3241,6 +3228,7 @@ module.exports = async ( ap.get('/api/gun/user/load/:path', async (req, res) => { const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER) const { path } = req.params + logger.info(`gun otheruser LOAD: ${path}`) try { const data = await handleGunFetch({ path, @@ -3268,7 +3256,7 @@ module.exports = async ( const allowedTypes = ['once', 'load', 'open'] const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER) const { path /*:rawPath*/, publicKey, type } = req.params - console.log(path) + logger.info(`gun otheruser ${type}: ${path}`) // const path = decodeURI(rawPath) if (!publicKey || publicKey === 'undefined') { res.status(400).json({ @@ -3308,6 +3296,7 @@ module.exports = async ( try { const { lightning } = LightningServices.services const { methodName } = req.params + logger.info(`lnd RPC: ${methodName}`) const args = req.body lightning[methodName](args, (err, lres) => { @@ -3337,7 +3326,7 @@ module.exports = async ( ap.post('/api/gun/put', async (req, res) => { try { const { path, value } = req.body - + logger.info(`gun PUT: ${path}`) await GunWriteRPC.put(path, value) res.status(200).json({ @@ -3357,7 +3346,7 @@ module.exports = async ( ap.post('/api/gun/set', async (req, res) => { try { const { path, value } = req.body - + logger.info(`gun PUT: ${path}`) const id = await GunWriteRPC.set(path, value) res.status(200).json({