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

Commit 624e89f9 by Sascha Depold

Use new log method

1 parent 8d02f36b
...@@ -19,9 +19,7 @@ module.exports = (function() { ...@@ -19,9 +19,7 @@ module.exports = (function() {
Query.prototype.run = function(sql) { Query.prototype.run = function(sql) {
this.sql = sql this.sql = sql
if (this.options.logging !== false) { this.sequelize.log('Executing (' + this.options.uuid + '): ' + this.sql)
this.options.logging('Executing (' + this.options.uuid + '): ' + this.sql)
}
var resultSet = [], var resultSet = [],
errorDetected = false, errorDetected = false,
......
...@@ -19,9 +19,7 @@ module.exports = (function() { ...@@ -19,9 +19,7 @@ module.exports = (function() {
Query.prototype.run = function(sql) { Query.prototype.run = function(sql) {
this.sql = sql this.sql = sql
if (this.options.logging !== false) { this.sequelize.log('Executing (' + this.options.uuid + '): ' + this.sql)
this.options.logging('Executing (' + this.options.uuid + '): ' + this.sql)
}
this.client.query(this.sql, function(err, results, fields) { this.client.query(this.sql, function(err, results, fields) {
this.emit('sql', this.sql) this.emit('sql', this.sql)
......
...@@ -27,9 +27,7 @@ module.exports = (function() { ...@@ -27,9 +27,7 @@ module.exports = (function() {
, query = this.client.query(sql) , query = this.client.query(sql)
, rows = [] , rows = []
if (this.options.logging !== false) { this.sequelize.log('Executing (' + this.options.uuid + '): ' + this.sql)
this.options.logging('Executing (' + this.options.uuid + '): ' + this.sql)
}
query.on('row', function(row) { query.on('row', function(row) {
rows.push(row) rows.push(row)
......
...@@ -26,9 +26,7 @@ module.exports = (function() { ...@@ -26,9 +26,7 @@ module.exports = (function() {
this.sql = sql this.sql = sql
if (this.options.logging !== false) { this.sequelize.log('Executing (' + this.options.uuid + '): ' + this.sql)
this.options.logging('Executing (' + this.options.uuid + '): ' + this.sql)
}
var columnTypes = {} var columnTypes = {}
this.database.serialize(function() { this.database.serialize(function() {
......
...@@ -15,16 +15,6 @@ module.exports = (function() { ...@@ -15,16 +15,6 @@ module.exports = (function() {
logging: console.log, logging: console.log,
filesFilter: /\.js$/ filesFilter: /\.js$/
}, options || {}) }, options || {})
if (this.options.logging === true) {
console.log('DEPRECATION WARNING: The logging-option should be either a function or false. Default: console.log')
this.options.logging = console.log
}
if (this.options.logging == console.log) {
// using just console.log will break in node < 0.6
this.options.logging = function(s) { console.log(s) }
}
} }
Object.defineProperty(Migrator.prototype, "queryInterface", { Object.defineProperty(Migrator.prototype, "queryInterface", {
...@@ -53,9 +43,9 @@ module.exports = (function() { ...@@ -53,9 +43,9 @@ module.exports = (function() {
} }
if (migrations.length === 0) { if (migrations.length === 0) {
self.options.logging("There are no pending migrations.") self.sequelize.log("There are no pending migrations.")
} else { } else {
self.options.logging("Running migrations...") self.sequelize.log("Running migrations...")
} }
migrations.forEach(function(migration) { migrations.forEach(function(migration) {
...@@ -63,9 +53,7 @@ module.exports = (function() { ...@@ -63,9 +53,7 @@ module.exports = (function() {
chainer.add(migration, 'execute', [options], { chainer.add(migration, 'execute', [options], {
before: function(migration) { before: function(migration) {
if (self.options.logging !== false) { self.sequelize.log(migration.filename)
self.options.logging(migration.filename)
}
migrationTime = process.hrtime() migrationTime = process.hrtime()
}, },
...@@ -73,9 +61,7 @@ module.exports = (function() { ...@@ -73,9 +61,7 @@ module.exports = (function() {
migrationTime = process.hrtime(migrationTime) migrationTime = process.hrtime(migrationTime)
migrationTime = Math.round( (migrationTime[0] * 1000) + (migrationTime[1] / 1000000)); migrationTime = Math.round( (migrationTime[0] * 1000) + (migrationTime[1] / 1000000));
if (self.options.logging !== false) { self.sequelize.log('Completed in ' + migrationTime + 'ms')
self.options.logging('Completed in ' + migrationTime + 'ms')
}
}, },
success: function(migration, callback) { success: function(migration, callback) {
...@@ -193,8 +179,10 @@ module.exports = (function() { ...@@ -193,8 +179,10 @@ module.exports = (function() {
return new Utils.CustomEventEmitter(function(emitter) { return new Utils.CustomEventEmitter(function(emitter) {
var chainer = new Utils.QueryChainer() var chainer = new Utils.QueryChainer()
var addMigration = function(filename) { var addMigration = function(filename) {
self.options.logging('Adding migration script at ' + filename)
var migration = new Migration(self, filename) var migration = new Migration(self, filename)
self.sequelize.log('Adding migration script at ' + filename)
chainer.add(migration, 'execute', [{ method: 'up' }], { chainer.add(migration, 'execute', [{ method: 'up' }], {
before: function(migration) { before: function(migration) {
if (options && Utils._.isFunction(options.before)) { if (options && Utils._.isFunction(options.before)) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!