From 1795d9f1c532a4aba56d2ac9b8b3fa9f8e748380 Mon Sep 17 00:00:00 2001 From: nioc Date: Mon, 25 Nov 2019 21:56:14 +0100 Subject: [PATCH] Fix logging multi-line message --- lib/outgoing/index.js | 2 +- lib/xmpp/index.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/outgoing/index.js b/lib/outgoing/index.js index 42dba33..9c2784d 100644 --- a/lib/outgoing/index.js +++ b/lib/outgoing/index.js @@ -74,7 +74,7 @@ module.exports = async (logger, config, xmpp, user, destination, message, type, if (statusCode === 200) { logger.trace('Response:', body) if (body && typeof (body) === 'object' && 'reply' in body === true) { - logger.debug(`There is a reply to send back in chat ${destination}: ${body.reply}`) + logger.debug(`There is a reply to send back in chat ${destination}: ${body.reply.replace(/\n|\r/g, ' ')}`) xmpp.send(destination, body.reply, type) return `Message sent. There is a reply to send back in chat ${destination}: ${body.reply}` } diff --git a/lib/xmpp/index.js b/lib/xmpp/index.js index 71b4311..177f8db 100644 --- a/lib/xmpp/index.js +++ b/lib/xmpp/index.js @@ -17,7 +17,7 @@ module.exports = (logger, config) => { // declare send chat/groupchat function this.send = async (to, message, type) => { - logger.debug(`Send ${type} message to ${to}: '${message}'`) + logger.debug(`Send ${type} message to ${to}: '${message.replace(/\n|\r/g, ' ')}'`) const stanza = xml( 'message', { to, @@ -125,7 +125,7 @@ module.exports = (logger, config) => { } } logger.info(`Incoming ${type} message from ${from} (${fromJid.toString()}) to ${to}`) - logger.debug(`Message: "${message}"`) + logger.debug(`Message: "${message.replace(/\n|\r/g, ' ')}"`) let xmppHook = config.getXmppHookAction(to.toString()) if (!xmppHook) { logger.error(`There is no action for incoming ${type} message to: "${to}"`)