1
0
Fork 0
mirror of synced 2024-06-26 18:10:51 +12:00
budibase/packages/backend-core/src/logging.ts

37 lines
731 B
TypeScript
Raw Normal View History

2022-05-31 21:16:22 +12:00
const NonErrors = ["AccountError"]
function isSuppressed(e?: any) {
2022-05-31 21:16:22 +12:00
return e && e["suppressAlert"]
}
export function logAlert(message: string, e?: any) {
2022-05-31 21:16:22 +12: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}`)
}
export function logAlertWithInfo(
message: string,
db: string,
id: string,
error: any
) {
message = `${message} - db: ${db} - doc: ${id} - error: `
logAlert(message, error)
}
export function logWarn(message: string) {
console.warn(`bb-warn: ${message}`)
2022-07-25 23:17:40 +12:00
}
export default {
logAlert,
logAlertWithInfo,
logWarn,
}