Skip to content

Commit

Permalink
Fix logging multi-line message
Browse files Browse the repository at this point in the history
  • Loading branch information
nioc committed Nov 25, 2019
1 parent 157dce7 commit 1795d9f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/outgoing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
}
Expand Down
4 changes: 2 additions & 2 deletions lib/xmpp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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}"`)
Expand Down

0 comments on commit 1795d9f

Please sign in to comment.