-
-
Save brunohcastro/5002f30a3344a33ca34d1cf0295cb08e to your computer and use it in GitHub Desktop.
A monitoring script based on Tulir's wa-web/web-scripts logging script, for 2.3000x
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!window.decodeStanza) { | |
window.decodeStanza = require("WAWap").decodeStanza; | |
window.encodeStanza = require("WAWap").encodeStanza; | |
} | |
require("WAWap").decodeStanza = async (e, t) => { | |
const result = await window.decodeStanza(e, t); | |
console.log('RECV', result.toString(), result); | |
return result; | |
} | |
require("WAWap").encodeStanza = (...args) => { | |
const result = window.encodeStanza(...args); | |
console.log('SEND', args[0].toString(), args[0]); | |
return result; | |
} | |
if (!window.loggerSet) { | |
const _logger = window.require("WAWebLoggerImpl").Logger | |
const _origLogImpl = _logger.logImpl.bind(_logger) | |
const logLevel = { | |
0: console.debug, | |
1: console.info, | |
2: console.log, | |
3: console.warn, | |
4: console.error, | |
5: console.error, | |
} | |
_logger.logImpl = (level, message, a, b, area) => { | |
const logArgs = [] | |
if (area) logArgs.push(`[${area}]`) | |
logArgs.push(message) | |
if (a || b) logArgs.push([a, b]) | |
logLevel[level](...logArgs) | |
_origLogImpl(level, message, a, b, area) | |
} | |
window.loggerSet = true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment