Home > Software design >  How can I add undeletable log to Devtools console?
How can I add undeletable log to Devtools console?

Time:11-10

I will make a presentation online and I will use Chrome dev tools. I want to add some useful information to myself and sometimes when I need to clear my console I want that information to remain there. For example, when I click the clear console button I want certain logs to stay there. Is this possible?

Devtools

CodePudding user response:

While it's not possible to create an "undeletable log", you can override console.clear's default behavior to clear the console but log the message again:

var log = console.clear;

const message = 'Hi!'

console.clear = function(e) {
  log.apply();
  console.log(message)
};

console.log(message)

console.log('Hello')
console.clear()
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

CodePudding user response:

what about e.g. https://developer.chrome.com/docs/devtools/console/reference#persist

cited: "Persist messages across page loads

By default the Console clears whenever you load a new page. To persist messages across page loads, Open Console Settings and then enable the Preserve Log checkbox."

Will it help?

  • Related