add_task(function test_StructuredLogger() {
let testBuffer = [];
let appendBuffer = function (msg) {
testBuffer.push(JSON.stringify(msg));
};
let assertLastMsg = function (refData) { // Check all fields in refData agree with those in the // last message logged, and pop that message.
let lastMsg = JSON.parse(testBuffer.pop()); for (let field in refData) {
deepEqual(lastMsg[field], refData[field]);
} // The logger should always set the source to the logger name.
equal(lastMsg.source, "test_log");
};
let logger = new StructuredLogger("test_log", appendBuffer);
// Regression test for bug 2007587: Logger gracefully handles clone failures.
let logger2 = new StructuredLogger("test_dump", appendBuffer2, globalThis); const extraNotCloneable = { notCloneable: () => {} };
logger2.info("Test non-cloneable", extraNotCloneable);
assertSeenMsg(
{
action: "log",
message: "Failed to cloneInto: Error: Permission denied to pass a Function via structured clone",
level: "ERROR",
},
extra => extra === undefined
);
assertSeenMsg(
{ action: "log", message: "Test non-cloneable", level: "INFO" },
extra => extra === extraNotCloneable
);
// Now verify the most common / desired behavior: clone where possible. const extraCloneable = { cloneable: "Yes I am" };
logger2.info("Test cloneable", extraCloneable);
equal(testBuffer.length, 0, "No messages unaccounted for");
});
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.6Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.