hi all
I got this error when using Bunyan with Sequelize (ORM for MySQL etc):
bunyan usage error: /Users/amills001c/some_project/node_modules/sequelize/lib/dialects/mysql/query.js:34: attempt to log with an unbound log method: `this` is: { DTRACE_NET_SERVER_CONNECTION: [Function],
it happens when I use this configuration with Sequelize
var Sequelize = require('sequelize');
var sequelize = new Sequelize('test', 'newuser', 'password',{
host: 'localhost',
dialect: 'mariadb',
logging: log.debug, // <<<< bunyan log.debug call
pool: {
max: 5,
min: 0,
idle: 10000
}
});
any idea what the underlying issue is? thanks for you help!
IIUC, this is the same as was hit in issue #100. See this comment: https://github.com/trentm/node-bunyan/issues/100#issuecomment-66028260 and this commit: https://github.com/trentm/node-bunyan/commit/2f95bb8091a8085756cc1f73c51dcf020f1990a2
You want:
...
logging: log.debug.bind(log)
...
thanks :)
The bind solution mentioned above gave me more information than I needed (it kept logging other options and query parameters that I didn't want to see and took up multiple lines). Instead I created a function that just passed the message into bunyan's log and gave the logging option the function instead. I don't know if this is the best way to add Bunyan in but it worked for me and only logged the query instead of all the other stuff.
const logger = (msg) => {
log.info(msg);
};
...
logging: logger
...
Most helpful comment
IIUC, this is the same as was hit in issue #100. See this comment: https://github.com/trentm/node-bunyan/issues/100#issuecomment-66028260 and this commit: https://github.com/trentm/node-bunyan/commit/2f95bb8091a8085756cc1f73c51dcf020f1990a2
You want: