mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
🩹 ConsoleLogger will always output error messages
This commit is contained in:
parent
31867b17d6
commit
4b30449ddb
2 changed files with 20 additions and 5 deletions
|
@ -24,10 +24,20 @@ export default class ConsoleLogger {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable logging. Only impacts `log()` output.
|
||||
*
|
||||
* @param {boolean} state True to enable log output.
|
||||
*/
|
||||
set enabled( state ) {
|
||||
this.#enabled = state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output log-level details to the browser console, if logging is enabled.
|
||||
*
|
||||
* @param {...any} args - All provided values are output to the browser console.
|
||||
*/
|
||||
log( ...args ) {
|
||||
if ( this.#enabled ) {
|
||||
// eslint-disable-next-line
|
||||
|
@ -35,9 +45,14 @@ export default class ConsoleLogger {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an error message in the browser's console.
|
||||
*
|
||||
* Error messages are always output, even when logging is disabled.
|
||||
*
|
||||
* @param {...any} args - All provided values are output to the browser console.
|
||||
*/
|
||||
error( ...args ) {
|
||||
if ( this.#enabled ) {
|
||||
console.error( this.#prefix, ...args );
|
||||
}
|
||||
console.error( this.#prefix, ...args );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue