Fix logging multi-line message

This commit is contained in:
nioc 2019-11-25 21:56:14 +01:00
parent 157dce7379
commit 1795d9f1c5
2 changed files with 3 additions and 3 deletions

View file

@ -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}`
}

View file

@ -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}"`)