Allows writing to a DOM element in console.log style. Element grows in size, so use something like overflow-y: scroll on its parent
overflow-y: scroll
const l = log(`#dataStream`); // Assumes HTML element with id `dataStream` existsl.log(`Hi`);l.log(); // Displays a horizontal ruleconst l = log(document.getElementById(`dataStream`), { timestamp: true, truncateEntries: 20});l.log(`Hi`);l.error(`Some error`); // Adds class `error` to line Copy
const l = log(`#dataStream`); // Assumes HTML element with id `dataStream` existsl.log(`Hi`);l.log(); // Displays a horizontal ruleconst l = log(document.getElementById(`dataStream`), { timestamp: true, truncateEntries: 20});l.log(`Hi`);l.error(`Some error`); // Adds class `error` to line
For logging high-throughput streams:
// Silently drop log if it was less than 5ms since the lastconst l = log(`#dataStream`, { minIntervalMs: 5 });// Only the last 100 entries are keptconst l = log(`#dataStream`, { capacity: 100 }); Copy
// Silently drop log if it was less than 5ms since the lastconst l = log(`#dataStream`, { minIntervalMs: 5 });// Only the last 100 entries are keptconst l = log(`#dataStream`, { capacity: 100 });
Element or id of element
Allows writing to a DOM element in console.log style. Element grows in size, so use something like
overflow-y: scroll
on its parentFor logging high-throughput streams: