From a214a4cd563b737fe876111fe9fe5c8e290943e9 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Thu, 27 Feb 2020 13:28:05 -0400 Subject: [PATCH] more logging --- services/gunDB/contact-api/events/index.js | 10 +++++++++- services/gunDB/contact-api/streams/pubToIncoming.js | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/services/gunDB/contact-api/events/index.js b/services/gunDB/contact-api/events/index.js index 01de9ba7..f652ba5d 100644 --- a/services/gunDB/contact-api/events/index.js +++ b/services/gunDB/contact-api/events/index.js @@ -326,6 +326,10 @@ const getCurrentOutgoings = () => currentOutgoings /** @type {Set} */ const outgoingsListeners = new Set() +outgoingsListeners.add(o => { + logger.info(`new outgoings: ${JSON.stringify(o, null, 4)}`) +}) + const notifyOutgoingsListeners = () => { outgoingsListeners.forEach(l => l(currentOutgoings)) } @@ -442,6 +446,10 @@ const getChats = () => currentChats /** @type {Set} */ const chatsListeners = new Set() +chatsListeners.add(c => { + logger.info(`new Chats: ${JSON.stringify(c, null, 4)}`) +}) + const notifyChatsListeners = () => { chatsListeners.forEach(l => l(currentChats)) } @@ -540,7 +548,7 @@ let currentBio = null * @param {(bio: string|null) => void} cb * @param {UserGUNNode} user Pass only for testing purposes. * @throws {Error} If user hasn't been auth. - * @returns {void} + * @returns {void}outgoingsListeners.forEach() */ const onBio = (cb, user) => { if (!user.is) { diff --git a/services/gunDB/contact-api/streams/pubToIncoming.js b/services/gunDB/contact-api/streams/pubToIncoming.js index ba2b156e..ae2c5a28 100644 --- a/services/gunDB/contact-api/streams/pubToIncoming.js +++ b/services/gunDB/contact-api/streams/pubToIncoming.js @@ -1,6 +1,7 @@ /** @format */ const uuidv1 = require('uuid/v1') const debounce = require('lodash/debounce') +const logger = require('winston') const { USER_TO_INCOMING } = require('../key') const { asyncForEach } = require('../utils') @@ -28,6 +29,12 @@ const setPubToIncoming = pti => { let latestUpdate = uuidv1() +listeners.add(() => { + logger.info( + `new pubToIncoming: ${JSON.stringify(getPubToIncoming(), null, 4)}` + ) +}) + const onOpen = debounce(async uti => { const SEA = require('../../Mediator').mySEA const mySec = require('../../Mediator').getMySecret()