How can I add undeletable log to Devtools console?

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

Answer

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()