reduce the size of the log entry by truncating any string values to 500 characters

This commit is contained in:
Hongbo Wu 2024-01-29 12:10:48 +08:00
parent d5d581fc54
commit 809c572ca7
2 changed files with 5 additions and 11 deletions

View file

@ -34,11 +34,9 @@ export class CustomTypeOrmLogger
}
logQuery(query: string, parameters?: any[], queryRunner?: QueryRunner) {
this.logger.info(
`query: ${query} -- PARAMETERS: ${super.stringifyParams(
parameters || []
)}`
)
this.logger.info(query, {
parameters,
})
}
log(
@ -133,10 +131,8 @@ const truncateObjectDeep = (object: any, length: number): any => {
class GcpLoggingTransport extends LoggingWinston {
log(info: any, callback: (err: Error | null, apiResponse?: any) => void) {
const sizeInfo = jsonStringify(info).length
if (sizeInfo > MAX_LOG_SIZE) {
info = truncateObjectDeep(info, 500) as never // the max length for string values is 500
}
// reduce the size of the log entry by truncating any string values to 500 characters
info = truncateObjectDeep(info, 500) as never
super.log(info, callback)
}
}

View file

@ -117,8 +117,6 @@ export const inboundEmailHandler = Sentry.GCPFunction.wrapHttpFunction(
}
}
const headers = parseHeaders(parsed.headers)
console.log('parsed: ', parsed)
console.log('headers: ', headers)
// original sender email address
const from = parsed['from']