Reputation: 634
I want to disable debug logging based on the host address. For instance, I want to keep debug logging for DEV and QA instances and disable console debug logs on productions. Currently, the way to disable debug logs is by using
$logProvider.enableDebug(false)
I want this call only on a specific URL and $location
is not available where $logProvider
is available.
Upvotes: 0
Views: 146
Reputation: 48211
You can use plain old JS window.location.host
. E.g.:
var listOfDebugEnabledHosts = [...];
app.config(function ($logProvider) {
var host = window.location.host;
var debugEnabled = listOfDebugEnabledHosts.indexOf(host) !== -1;
$logProvider.debugEnabled(debugEnabled);
});
Upvotes: 1
Reputation: 5126
I would recommend using: https://github.com/sunnykgupta/jsLogger
Features:
Disclaimer: I am the author of the plugin.
Upvotes: 0