2022-05-31 11:16:22 +02:00
|
|
|
const NonErrors = ["AccountError"]
|
|
|
|
|
2022-07-06 15:04:04 +02:00
|
|
|
function isSuppressed(e?: any) {
|
2022-05-31 11:16:22 +02:00
|
|
|
return e && e["suppressAlert"]
|
|
|
|
}
|
|
|
|
|
2022-07-06 15:04:04 +02:00
|
|
|
export function logAlert(message: string, e?: any) {
|
2022-05-31 11:16:22 +02:00
|
|
|
if (e && NonErrors.includes(e.name) && isSuppressed(e)) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
let errorJson = ""
|
|
|
|
if (e) {
|
|
|
|
errorJson = ": " + JSON.stringify(e, Object.getOwnPropertyNames(e))
|
|
|
|
}
|
|
|
|
console.error(`bb-alert: ${message} ${errorJson}`)
|
|
|
|
}
|
2022-07-06 15:04:04 +02:00
|
|
|
|
2022-07-20 23:38:06 +02:00
|
|
|
export function logAlertWithInfo(
|
|
|
|
message: string,
|
|
|
|
db: string,
|
|
|
|
id: string,
|
|
|
|
error: any
|
|
|
|
) {
|
|
|
|
message = `${message} - db: ${db} - doc: ${id} - error: `
|
|
|
|
logAlert(message, error)
|
|
|
|
}
|
|
|
|
|
2022-07-25 13:23:30 +02:00
|
|
|
export function logWarn(message: string) {
|
|
|
|
console.warn(`bb-warn: ${message}`)
|
2022-07-25 13:17:40 +02:00
|
|
|
}
|
|
|
|
|
2022-07-06 15:04:04 +02:00
|
|
|
export default {
|
|
|
|
logAlert,
|
2022-07-20 23:38:06 +02:00
|
|
|
logAlertWithInfo,
|
2022-07-25 13:23:30 +02:00
|
|
|
logWarn,
|
2022-07-06 15:04:04 +02:00
|
|
|
}
|