Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use with Sequelize ORM debug logging - unbound log method #350

Closed
ORESoftware opened this issue Feb 10, 2016 · 3 comments
Closed

Use with Sequelize ORM debug logging - unbound log method #350

ORESoftware opened this issue Feb 10, 2016 · 3 comments

Comments

@ORESoftware
Copy link

@ORESoftware ORESoftware commented Feb 10, 2016

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!

@ORESoftware ORESoftware changed the title Use with Sequelize ORM debug logging Use with Sequelize ORM debug logging - unbound log method -uh oh Feb 10, 2016
@ORESoftware ORESoftware changed the title Use with Sequelize ORM debug logging - unbound log method -uh oh Use with Sequelize ORM debug logging - unbound log method Feb 10, 2016
@trentm

This comment has been minimized.

Copy link
Owner

@trentm trentm commented Feb 10, 2016

IIUC, this is the same as was hit in issue #100. See this comment: #100 (comment) and this commit: 2f95bb8

You want:

...
    logging: log.debug.bind(log)
...
@ORESoftware

This comment has been minimized.

Copy link
Author

@ORESoftware ORESoftware commented Feb 10, 2016

thanks :)

@thomasstep

This comment has been minimized.

Copy link

@thomasstep thomasstep commented Oct 14, 2019

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
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.