不要怂,就是干,撸起袖子干!

Commit ab2f0764 by Samuli Asmala Committed by Pedro Augusto de Paula Barbosa

docs: describe logging option (#11654)

1 parent 71d124c4
Showing with 17 additions and 0 deletions
...@@ -69,6 +69,23 @@ const sequelize = new Sequelize(/* ... */, { ...@@ -69,6 +69,23 @@ const sequelize = new Sequelize(/* ... */, {
Learn more in the [API Reference for the Sequelize constructor](../class/lib/sequelize.js~Sequelize.html#instance-constructor-constructor). If you're connecting to the database from multiple processes, you'll have to create one instance per process, but each instance should have a maximum connection pool size of such that the total maximum size is respected. For example, if you want a max connection pool size of 90 and you have three processes, the Sequelize instance of each process should have a max connection pool size of 30. Learn more in the [API Reference for the Sequelize constructor](../class/lib/sequelize.js~Sequelize.html#instance-constructor-constructor). If you're connecting to the database from multiple processes, you'll have to create one instance per process, but each instance should have a maximum connection pool size of such that the total maximum size is respected. For example, if you want a max connection pool size of 90 and you have three processes, the Sequelize instance of each process should have a max connection pool size of 30.
### Note: setting up logging
Using `options.logging` can be used to define the function that gets executed every time Sequelize would log something. The default value is `console.log` and when using that only the first log parameter of log function call is displayed. For example, for query logging the first parameter is the raw query and the second (hidden by default) is the Sequelize object.
Common useful values for `options.logging`:
```js
const sequelize = new Sequelize(/* ... */, {
// Choose one of the logging options
logging: console.log, // Default, displays the first parameter of the log function call
logging: (...msg) => console.log(msg), // Displays all log function call parameters
logging: false, // Disables logging
logging: msg => logger.debug(msg), // Use custom logger (e.g. Winston or Bunyan), displays the first parameter
logging: logger.debug.bind(logger) // Alternative way to use custom logger, displays all messages
});
```
### Testing the connection ### Testing the connection
You can use the `.authenticate()` function to test if the connection is OK: You can use the `.authenticate()` function to test if the connection is OK:
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!