Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 89441cb1
authored
Apr 13, 2012
by
Ken Perkins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaning up to overload options.logging while still providing support for a custom logging function
1 parent
744c5d86
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
22 deletions
lib/dialects/mysql/query.js
lib/dialects/sqlite/query.js
lib/migrator.js
lib/sequelize.js
lib/dialects/mysql/query.js
View file @
89441cb
...
...
@@ -7,7 +7,7 @@ module.exports = (function() {
this
.
client
=
client
this
.
callee
=
callee
this
.
options
=
Utils
.
_
.
extend
({
logging
:
true
,
logging
:
console
.
log
,
plain
:
false
,
raw
:
false
},
options
||
{})
...
...
@@ -23,10 +23,8 @@ module.exports = (function() {
bindClient
.
call
(
this
)
if
((
this
.
options
.
logging
)
&&
(
this
.
options
.
customLogger
))
this
.
options
.
customLogger
(
'Executing: '
+
this
.
sql
)
else
if
(
this
.
options
.
logging
)
console
.
log
(
'Executing: '
+
this
.
sql
)
if
(
this
.
options
.
logging
!==
false
)
this
.
options
.
logging
(
'Executing: '
+
this
.
sql
)
this
.
client
.
query
(
this
.
sql
,
function
(
err
,
results
,
fields
)
{
self
.
emit
(
'sql'
,
self
.
sql
)
...
...
lib/dialects/sqlite/query.js
View file @
89441cb
...
...
@@ -5,7 +5,7 @@ module.exports = (function() {
this
.
database
=
database
this
.
callee
=
callee
this
.
options
=
Utils
.
_
.
extend
({
logging
:
true
,
logging
:
console
.
log
,
plain
:
false
,
raw
:
false
},
options
||
{})
...
...
@@ -17,10 +17,8 @@ module.exports = (function() {
this
.
sql
=
sql
if
((
this
.
options
.
logging
)
&&
(
this
.
options
.
customLogger
))
this
.
options
.
customLogger
(
'Executing: '
+
this
.
sql
)
else
if
(
this
.
options
.
logging
)
console
.
log
(
'Executing: '
+
this
.
sql
)
if
(
this
.
options
.
logging
!==
false
)
this
.
options
.
logging
(
'Executing: '
+
this
.
sql
)
this
.
database
.
serialize
(
function
()
{
var
isInsertCommand
=
(
self
.
sql
.
toLowerCase
().
indexOf
(
'insert'
)
==
0
)
...
...
lib/migrator.js
View file @
89441cb
...
...
@@ -13,7 +13,7 @@ module.exports = (function() {
path
:
__dirname
+
'/../migrations'
,
from
:
null
,
to
:
null
,
logging
:
true
logging
:
console
.
log
},
options
||
{})
}
...
...
@@ -46,16 +46,12 @@ module.exports = (function() {
migrations
.
forEach
(
function
(
migration
)
{
chainer
.
add
(
migration
,
'execute'
,
[
options
],
{
before
:
function
(
migration
)
{
if
((
self
.
options
.
logging
)
&&
(
self
.
options
.
customLogger
))
self
.
options
.
customLogger
(
'Executing migration: '
+
migration
.
filename
)
else
if
(
self
.
options
.
logging
)
console
.
log
(
'Executing migration: '
+
migration
.
filename
)
if
(
self
.
options
.
logging
!==
false
)
self
.
options
.
logging
(
'Executing migration: '
+
migration
.
filename
)
},
after
:
function
(
migration
)
{
if
((
self
.
options
.
logging
)
&&
(
self
.
options
.
customLogger
))
self
.
options
.
customLogger
(
'Executed migration: '
+
migration
.
filename
)
else
if
(
self
.
options
.
logging
)
console
.
log
(
'Executed migration: '
+
migration
.
filename
)
if
(
self
.
options
.
logging
!==
false
)
self
.
options
.
logging
(
'Executed migration: '
+
migration
.
filename
)
},
success
:
function
(
migration
,
callback
)
{
if
(
options
.
method
==
'down'
)
...
...
lib/sequelize.js
View file @
89441cb
...
...
@@ -72,9 +72,7 @@ module.exports = (function() {
Sequelize
.
prototype
.
query
=
function
(
sql
,
callee
,
options
)
{
options
=
Utils
.
_
.
extend
(
Utils
.
_
.
clone
(
this
.
options
.
query
),
options
||
{})
options
=
Utils
.
_
.
extend
(
options
,
{
logging
:
this
.
options
.
hasOwnProperty
(
'logging'
)
?
this
.
options
.
logging
:
true
,
customLogger
:
this
.
options
.
hasOwnProperty
(
'customLogger'
)
&&
typeof
(
this
.
options
.
customLogger
)
===
'function'
?
this
.
options
.
customLogger
:
undefined
logging
:
this
.
options
.
hasOwnProperty
(
'logging'
)
?
this
.
options
.
logging
:
console
.
log
})
return
this
.
connectorManager
.
query
(
sql
,
callee
,
options
)
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment