Skip to content

Commit

Permalink
API-1 - Logging API codeless block improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
macbookpro committed Feb 19, 2024
1 parent 1745d50 commit a3e562a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/logging/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default class Logging {

push(logger, logLevel, message, exception) {
if (typeof message !== 'string') {
throw new Error('"message" must be a string')
message = this.convertMessageToString(message)
}

this.messages.push({ logger, message, exception, 'log-level': logLevel, timestamp: Date.now() })
Expand Down Expand Up @@ -161,4 +161,12 @@ export default class Logging {
this.checkMessagesLimit()
}

convertMessageToString(message) {
if(typeof message !== 'string') {
message = JSON.stringify(message)
}

return message
}

}

0 comments on commit a3e562a

Please sign in to comment.