debug icon indicating copy to clipboard operation
debug copied to clipboard

Way to disable printf-style feature temporarily

Open sdepold opened this issue 1 year ago • 0 comments

We are seeing some interesting side-effect of the printf-style feature outlined here: https://github.com/sequelize/sequelize/issues/17448

Long story short, we are using debug to print SQL queries that are executed against database servers and whenever people use a like or ilike query in combination with % at the beginning, it sometimes happens that the logs show NaN. This happens when the search term starts with any of the printf-style characters, e.g. for something like SELECT * FROM foo WHERE name LIKE %fauzi%. The logs will then contain NaNauzi.

Would it be possible to force a debug log statement to ignore any printf formatting?

Something like:

const log = debug('sql')

log("%fauzi%", { printfFormatting: false})

sdepold avatar Nov 09 '24 15:11 sdepold