mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 13:44:42 +08:00
Consolidate logging
This commit is contained in:
parent
4c9ccebd10
commit
1524d03ba2
2 changed files with 45 additions and 53 deletions
|
@ -1,4 +1,26 @@
|
|||
export function log(message, level = 'info') {
|
||||
const endpoint = this.axoConfig?.ajax?.frontend_logger?.endpoint;
|
||||
if(!endpoint) {
|
||||
return;
|
||||
}
|
||||
|
||||
export function log(...args) {
|
||||
//console.log('[AXO] ', ...args);
|
||||
fetch(endpoint, {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
body: JSON.stringify({
|
||||
nonce: this.axoConfig.ajax.frontend_logger.nonce,
|
||||
log: {
|
||||
message,
|
||||
level,
|
||||
}
|
||||
})
|
||||
}).then(() => {
|
||||
switch (level) {
|
||||
case 'error':
|
||||
console.error(`[AXO] ${message}`);
|
||||
break;
|
||||
default:
|
||||
console.log(`[AXO] ${message}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue