chore: proper error log format (#8105)
Fix some error log formatting to use `{ msg, err }` properly
This commit is contained in:
@@ -5,13 +5,13 @@ export const recordLastLoggedInTenant: AfterLoginHook = async ({ req, user }) =>
|
|||||||
const relatedOrg = await req.payload
|
const relatedOrg = await req.payload
|
||||||
.find({
|
.find({
|
||||||
collection: 'tenants',
|
collection: 'tenants',
|
||||||
|
depth: 0,
|
||||||
|
limit: 1,
|
||||||
where: {
|
where: {
|
||||||
'domains.domain': {
|
'domains.domain': {
|
||||||
in: [req.headers.host],
|
in: [req.headers.host],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
depth: 0,
|
|
||||||
limit: 1,
|
|
||||||
})
|
})
|
||||||
?.then((res) => res.docs?.[0])
|
?.then((res) => res.docs?.[0])
|
||||||
|
|
||||||
@@ -24,7 +24,10 @@ export const recordLastLoggedInTenant: AfterLoginHook = async ({ req, user }) =>
|
|||||||
req,
|
req,
|
||||||
})
|
})
|
||||||
} catch (err: unknown) {
|
} catch (err: unknown) {
|
||||||
req.payload.logger.error(`Error recording last logged in tenant for user ${user.id}: ${err}`)
|
req.payload.logger.error({
|
||||||
|
err,
|
||||||
|
msg: `Error recording last logged in tenant for user ${user.id}`,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return user
|
return user
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ const connectWithReconnect = async function ({
|
|||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
result = await adapter.pool.connect()
|
result = await adapter.pool.connect()
|
||||||
} catch (err) {
|
} catch (ignore) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
payload.logger.info('Reconnecting to postgres')
|
payload.logger.info('Reconnecting to postgres')
|
||||||
void connectWithReconnect({ adapter, payload, reconnect: true })
|
void connectWithReconnect({ adapter, payload, reconnect: true })
|
||||||
@@ -38,7 +38,7 @@ const connectWithReconnect = async function ({
|
|||||||
if (err.code === 'ECONNRESET') {
|
if (err.code === 'ECONNRESET') {
|
||||||
void connectWithReconnect({ adapter, payload, reconnect: true })
|
void connectWithReconnect({ adapter, payload, reconnect: true })
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (ignore) {
|
||||||
// swallow error
|
// swallow error
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -76,7 +76,7 @@ export const connect: Connect = async function connect(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.payload.logger.error(`Error: cannot connect to Postgres. Details: ${err.message}`, err)
|
this.payload.logger.error({ err, msg: `Error: cannot connect to Postgres: ${err.message}` })
|
||||||
if (typeof this.rejectInitializing === 'function') {
|
if (typeof this.rejectInitializing === 'function') {
|
||||||
this.rejectInitializing()
|
this.rejectInitializing()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export const connect: Connect = async function connect(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.payload.logger.error(`Error: cannot connect to SQLite. Details: ${err.message}`, err)
|
this.payload.logger.error({ err, msg: `Error: cannot connect to SQLite: ${err.message}` })
|
||||||
if (typeof this.rejectInitializing === 'function') {
|
if (typeof this.rejectInitializing === 'function') {
|
||||||
this.rejectInitializing()
|
this.rejectInitializing()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export const connect: Connect = async function connect(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.payload.logger.error(`Error: cannot connect to Postgres. Details: ${err.message}`, err)
|
this.payload.logger.error({ err, msg: `Error: cannot connect to Postgres: ${err.message}` })
|
||||||
if (typeof this.rejectInitializing === 'function') {
|
if (typeof this.rejectInitializing === 'function') {
|
||||||
this.rejectInitializing()
|
this.rejectInitializing()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ export const beginTransaction: BeginTransaction = async function beginTransactio
|
|||||||
return done
|
return done
|
||||||
}
|
}
|
||||||
reject = () => {
|
reject = () => {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
|
||||||
rej()
|
rej()
|
||||||
return done
|
return done
|
||||||
}
|
}
|
||||||
@@ -57,7 +58,7 @@ export const beginTransaction: BeginTransaction = async function beginTransactio
|
|||||||
resolve,
|
resolve,
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.payload.logger.error(`Error: cannot begin transaction: ${err.message}`, err)
|
this.payload.logger.error({ err, msg: `Error: cannot begin transaction: ${err.message}` })
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user