Configuring logging with all of the available interfaces
Sequelize offers a few overload signatures for incorporating logs into an application. The default behavior is to call console.log
for each query. The following is a list of signatures that Sequelize will abide by:
function (msg) {}
function (...msg) {}
true
/false
msg => someLogger.debug(msg)
someLogger.debug.bind(someLogger)
If we wanted to customize Sequelize’s logging behavior, the following example would be a quick introduction to how to do so:
function customLog(msg) { // insert into db/logger app here // ... // and output to stdout console.log(msg); } const sequelize = new Sequelize('sqlite::memory:', { logging: customLog });
In addition to Sequelize sending the SQL queries into our customLog
function, we are also given a helper method for when we...