Closed Drejerdk closed 7 months ago
The best would be to clearly have an option 'logParam' and all error have either just :
For debugging, loggin parameters might help a lot, but for security reason, some might not want to have the parameters logged, so that correction will be done. This might not be exactly what you had in mind, you'll tell.
3.2.3 that has been released permit finer details on that : 2 options defined what will be logged : debugLen
and logParam
.
debuglen
defined string length of logged message / error or trace
logParam
indicate if parameters must be logged by query logger.
example of logParam: when false, some errors :
SqlError: (conn=-1, no: 45051, SQLState: 22000) Execute fails, prepare command as already been closed
sql: select ?
at module.exports.createError (C:\projects\mariadb-connector-nodejs\lib\misc\errors.js:64:10)
at PrepareResultPacket.execute (C:\projects\mariadb-connector-nodejs\lib\cmd\class\prepare-result-packet.js:51:28)
at Context.<anonymous> (C:\projects\mariadb-connector-nodejs\test\integration\test-execute.js:267:21)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
sqlMessage: 'Execute fails, prepare command as already been closed',
sql: 'select ?',
fatal: false,
errno: 45051,
sqlState: '22000',
code: 'ER_PREPARE_CLOSED'
}
when enable:
SqlError: (conn=-1, no: 45051, SQLState: 22000) Execute fails, prepare command as already been closed
sql: select ? - parameters:['1']
at module.exports.createError (C:\projects\mariadb-connector-nodejs\lib\misc\errors.js:64:10)
at PrepareResultPacket.execute (C:\projects\mariadb-connector-nodejs\lib\cmd\class\prepare-result-packet.js:51:28)
at Context.<anonymous> (C:\projects\mariadb-connector-nodejs\test\integration\test-execute.js:267:21)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
sqlMessage: 'Execute fails, prepare command as already been closed',
sql: "select ? - parameters:['1']",
fatal: false,
errno: 45051,
sqlState: '22000',
code: 'ER_PREPARE_CLOSED'
}
Sometimes I wish it was easier to get the full query and parameters of a query that is throwing an error.
Could it be considered adding a copy of
cmdParam
as the 2nd parameter when calling custom loggers withthis.opts.logger.error(err)
?