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 744c5d86
authored
Apr 13, 2012
by
Ken Perkins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding the ability to provide a custom logging function in lieu of console.log
1 parent
3bd86036
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
6 deletions
lib/dialects/mysql/query.js
lib/dialects/sqlite/query.js
lib/migrator.js
lib/sequelize.js
lib/dialects/mysql/query.js
View file @
744c5d8
...
...
@@ -23,10 +23,11 @@ module.exports = (function() {
bindClient
.
call
(
this
)
if
(
this
.
options
.
logging
)
if
((
this
.
options
.
logging
)
&&
(
this
.
options
.
customLogger
))
this
.
options
.
customLogger
(
'Executing: '
+
this
.
sql
)
else
if
(
this
.
options
.
logging
)
console
.
log
(
'Executing: '
+
this
.
sql
)
this
.
client
.
query
(
this
.
sql
,
function
(
err
,
results
,
fields
)
{
self
.
emit
(
'sql'
,
self
.
sql
)
err
?
onFailure
.
call
(
self
,
err
)
:
onSuccess
.
call
(
self
,
results
,
fields
)
...
...
lib/dialects/sqlite/query.js
View file @
744c5d8
...
...
@@ -17,7 +17,9 @@ module.exports = (function() {
this
.
sql
=
sql
if
(
this
.
options
.
logging
)
if
((
this
.
options
.
logging
)
&&
(
this
.
options
.
customLogger
))
this
.
options
.
customLogger
(
'Executing: '
+
this
.
sql
)
else
if
(
this
.
options
.
logging
)
console
.
log
(
'Executing: '
+
this
.
sql
)
this
.
database
.
serialize
(
function
()
{
...
...
lib/migrator.js
View file @
744c5d8
...
...
@@ -46,11 +46,15 @@ module.exports = (function() {
migrations
.
forEach
(
function
(
migration
)
{
chainer
.
add
(
migration
,
'execute'
,
[
options
],
{
before
:
function
(
migration
)
{
if
(
self
.
options
.
logging
)
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
)
},
after
:
function
(
migration
)
{
if
(
self
.
options
.
logging
)
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
)
},
success
:
function
(
migration
,
callback
)
{
...
...
lib/sequelize.js
View file @
744c5d8
...
...
@@ -72,7 +72,9 @@ 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
logging
:
this
.
options
.
hasOwnProperty
(
'logging'
)
?
this
.
options
.
logging
:
true
,
customLogger
:
this
.
options
.
hasOwnProperty
(
'customLogger'
)
&&
typeof
(
this
.
options
.
customLogger
)
===
'function'
?
this
.
options
.
customLogger
:
undefined
})
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