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

Commit 79c1f73c by sdepold

use wrapped console.log function if console.log is passed as logging method

1 parent 7ea1f5f4
...@@ -12,6 +12,16 @@ module.exports = (function() { ...@@ -12,6 +12,16 @@ module.exports = (function() {
raw: false raw: false
}, 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) }
}
this.bindClientFunction = function(err) { onFailure.call(self, err) } this.bindClientFunction = function(err) { onFailure.call(self, err) }
} }
Utils._.extend(Query.prototype, require("../query").prototype) Utils._.extend(Query.prototype, require("../query").prototype)
......
...@@ -9,6 +9,16 @@ module.exports = (function() { ...@@ -9,6 +9,16 @@ module.exports = (function() {
plain: false, plain: false,
raw: false raw: false
}, 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) }
}
} }
Utils._.extend(Query.prototype, require("../query").prototype) Utils._.extend(Query.prototype, require("../query").prototype)
...@@ -17,8 +27,9 @@ module.exports = (function() { ...@@ -17,8 +27,9 @@ module.exports = (function() {
this.sql = sql this.sql = sql
if(this.options.logging !== false) if(this.options.logging !== false) {
this.options.logging('Executing: ' + this.sql) this.options.logging('Executing: ' + this.sql)
}
this.database.serialize(function() { this.database.serialize(function() {
var isInsertCommand = (self.sql.toLowerCase().indexOf('insert') == 0) var isInsertCommand = (self.sql.toLowerCase().indexOf('insert') == 0)
......
...@@ -20,6 +20,11 @@ module.exports = (function() { ...@@ -20,6 +20,11 @@ module.exports = (function() {
console.log('DEPRECATION WARNING: The logging-option should be either a function or false. Default: console.log') console.log('DEPRECATION WARNING: The logging-option should be either a function or false. Default: console.log')
this.options.logging = 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", {
......
...@@ -13,7 +13,8 @@ module.exports = (function() { ...@@ -13,7 +13,8 @@ module.exports = (function() {
port: 3306, port: 3306,
define: {}, define: {},
query: {}, query: {},
sync: {} sync: {},
logging: console.log
}, options || {}) }, options || {})
if(this.options.logging === true) { if(this.options.logging === true) {
......
...@@ -11,7 +11,7 @@ describe('SQLite', function() { ...@@ -11,7 +11,7 @@ describe('SQLite', function() {
var self = this var self = this
this.sequelize = new Sequelize(config.database, config.username, config.password, { this.sequelize = new Sequelize(config.database, config.username, config.password, {
logging: true, logging: false,
dialect: 'sqlite' dialect: 'sqlite'
}) })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!