Skip to content

Commit

Permalink
refactor: remove log rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
dead-horse authored and fengmk2 committed Aug 13, 2018
1 parent c9afe1c commit e4b525e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
13 changes: 3 additions & 10 deletions lib/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,11 @@ const path = require('path');
const Sequelize = require('sequelize');
const MODELS = Symbol('loadedModels');
const AUTH_RETRIES = Symbol('authenticateRetries');
const chalk = require('chalk');
const sleep = require('mz-modules/sleep');

Sequelize.prototype.log = function() {
if (this.options.logging === false) { return; }
const args = Array.prototype.slice.call(arguments);
const sql = args[0].replace(/Executed \(.+?\):\s{0,1}/, '');
this.options.logging.info('[model]', chalk.magenta(sql), `(${args[1]}ms)`);
};

module.exports = app => {
const defaultConfig = {
logging: app.logger,
logging: app.logger.info.bind(app.logger),
host: 'localhost',
port: 3306,
username: 'root',
Expand All @@ -26,9 +18,10 @@ module.exports = app => {
underscored: true,
},
};

const config = Object.assign(defaultConfig, app.config.sequelize);

app.Sequelize = Sequelize;
app.Sequelize = config.Sequelize;

const sequelize = new Sequelize(config.database, config.username, config.password, config);

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
],
"dependencies": {
"@types/sequelize": "^4.27.14",
"chalk": "^2.0.1",
"mkdirp": "^0.5.1",
"mz-modules": "^2.1.0",
"sequelize": "^4.4.2",
Expand Down

0 comments on commit e4b525e

Please sign in to comment.