Last active
October 23, 2017 13:06
-
-
Save gabriel-dehan/fd9cd0db1c35255637caf81114b4348e to your computer and use it in GitHub Desktop.
cryptohelp
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
var target = $(".log")[0]; | |
var log = {}; | |
// level 3 error | |
// level 2 warn | |
// level 1 info | |
// level 0 debug | |
var observer = new MutationObserver(function(mutations) { | |
mutations.forEach(function(mutation) { | |
if (mutation.addedNodes.length > 0) { | |
var node = $(mutation.addedNodes[0]), | |
classes = node.attr('class'); | |
if (classes.match(/level/)) { | |
var level = classes; | |
var time = node.find(".time").text(); | |
var text = node.find(".message").text(); | |
log[time] = log[time] || [] | |
log[time].push({ | |
level: level, | |
message: message | |
}); | |
} | |
} | |
}); | |
}); | |
// configuration of the observer: | |
var config = { attributes: true, childList: true, characterData: true }; | |
// pass in the target node, as well as the observer options | |
observer.observe(target, config); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment