odebroqueville / contextSearch

Firefox add-on to search selected text in a web page using your favorite search engines from a context menu or from a grid of icons.
Other
19 stars 2 forks source link

Disable extension debugging messages #156

Closed Septh closed 9 months ago

Septh commented 9 months ago

Hi, the extension is generating a lot of noise in the browser console, which is a real burden when trying to debug my own code. Could you please disable this in the production build? 🙏

image

odebroqueville commented 9 months ago

Sorry about that! I have 3 files using a console logging variable and one slipped through the cracks! Whenever I code, I set all 3 debugging variables to true and when I'm finished I have to set all 3 variables back to false for production. It's a bit of a nuisance really and I'm wondering if there's not a way to automate this process?

Septh commented 9 months ago

I am not familiar with browser extension development but I think runtime.onInstalled can help, something like:

let logToConsole = false
browser.runtime.onInstalled.addListener(evt => {
    logToConsole = evt.temporary
});

function log(...args) {
    if (logToConsole) console.log(...args)
}
odebroqueville commented 9 months ago

@Septh Nice one! Thank you, Stephan!