-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16393 from nsoranzo/merge_release_23.1
Merge release_23.1 into dev
- Loading branch information
Showing
17 changed files
with
290 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* This module disables the console in production, | ||
* and adds the ability to toggle console logging | ||
* using the global functions | ||
* enableDebugging() and disableDebugging() | ||
*/ | ||
import { useLocalStorage } from "@vueuse/core"; | ||
import { watch } from "vue"; | ||
|
||
export function overrideProductionConsole() { | ||
let defaultEnabled = true; | ||
|
||
if (process.env.NODE_ENV == "production") { | ||
defaultEnabled = false; | ||
} | ||
|
||
const isEnabled = useLocalStorage("console-debugging-enabled", defaultEnabled); | ||
|
||
let storedConsole = null; | ||
|
||
const disableConsole = () => { | ||
storedConsole = console; | ||
// eslint-disable-next-line no-global-assign | ||
console = {}; | ||
Object.keys(storedConsole).forEach((key) => { | ||
console[key] = () => {}; | ||
}); | ||
}; | ||
|
||
const enableConsole = () => { | ||
if (storedConsole) { | ||
// eslint-disable-next-line no-global-assign | ||
console = storedConsole; | ||
} | ||
}; | ||
|
||
watch( | ||
() => isEnabled.value, | ||
(enabled) => { | ||
if (enabled) { | ||
enableConsole(); | ||
} else { | ||
disableConsole(); | ||
} | ||
}, | ||
{ immediate: true } | ||
); | ||
|
||
window.enableDebugging = () => { | ||
isEnabled.value = true; | ||
}; | ||
|
||
window.disableDebugging = () => { | ||
isEnabled.value = false; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.