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 cd364aad
authored
Mar 28, 2014
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow passing of winston options
1 parent
fe4eef85
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
1 deletions
lib/sequelize.js
test/sequelize/log.test.js
lib/sequelize.js
View file @
cd364aa
...
@@ -496,7 +496,15 @@ module.exports = (function() {
...
@@ -496,7 +496,15 @@ module.exports = (function() {
Object
.
defineProperty
(
Sequelize
.
prototype
,
'logger'
,
{
Object
.
defineProperty
(
Sequelize
.
prototype
,
'logger'
,
{
get
:
function
()
{
get
:
function
()
{
return
(
this
.
_logger
=
(
this
.
_logger
||
winston
))
if
(
!
this
.
_logger
)
{
if
(
Sequelize
.
Utils
.
isHash
(
this
.
options
.
logging
))
{
this
.
_logger
=
new
winston
.
Logger
(
this
.
options
.
logging
)
}
else
{
this
.
_logger
=
winston
}
}
return
this
.
_logger
}
}
})
})
...
...
test/sequelize/log.test.js
View file @
cd364aa
var
chai
=
require
(
'chai'
)
var
chai
=
require
(
'chai'
)
,
sinonChai
=
require
(
"sinon-chai"
)
,
sinonChai
=
require
(
"sinon-chai"
)
,
sinon
=
require
(
'sinon'
)
,
sinon
=
require
(
'sinon'
)
,
winston
=
require
(
'winston'
)
,
fs
=
require
(
'fs'
)
,
path
=
require
(
'path'
)
,
expect
=
chai
.
expect
,
expect
=
chai
.
expect
,
assert
=
chai
.
assert
,
assert
=
chai
.
assert
,
Support
=
require
(
__dirname
+
'/../support'
)
,
Support
=
require
(
__dirname
+
'/../support'
)
...
@@ -81,5 +84,42 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () {
...
@@ -81,5 +84,42 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () {
expect
(
this
.
spy
.
calledOnce
).
to
.
be
.
true
expect
(
this
.
spy
.
calledOnce
).
to
.
be
.
true
})
})
})
})
describe
(
"with custom winston options"
,
function
()
{
beforeEach
(
function
()
{
this
.
logFile
=
path
.
normalize
(
__dirname
+
'/../tmp/sequelize.log'
)
if
(
fs
.
existsSync
(
this
.
logFile
))
{
fs
.
unlinkSync
(
this
.
logFile
)
}
this
.
spy
=
sinon
.
spy
()
this
.
sequelize
=
new
Support
.
Sequelize
(
'db'
,
'user'
,
'pw'
,
{
logging
:
{
transports
:
[
new
winston
.
transports
.
File
({
filename
:
this
.
logFile
})
]
}
})
})
afterEach
(
function
()
{
if
(
fs
.
existsSync
(
this
.
logFile
))
{
fs
.
unlinkSync
(
this
.
logFile
)
}
})
it
(
"calls the custom logger method"
,
function
(
done
)
{
var
self
=
this
expect
(
fs
.
existsSync
(
this
.
logFile
)).
to
.
be
.
false
this
.
sequelize
.
log
(
'om nom'
)
setTimeout
(
function
()
{
expect
(
fs
.
existsSync
(
self
.
logFile
)).
to
.
be
.
true
done
()
},
100
)
})
})
})
})
})
})
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