Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
4e490488
...
4e49048821fff46037fe41b2a6935ccfd00b5ff7
authored
2011-12-08 20:05:30 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
refactored Casper.log(), added Casper.logFormats to setup custom log message formatters
1 parent
a2282c1c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
6 deletions
casper.js
casper.js
View file @
4e49048
...
...
@@ -71,6 +71,7 @@
this
.
delayedExecution
=
false
;
this
.
history
=
[];
this
.
loadInProgress
=
false
;
this
.
logFormats
=
{};
this
.
logLevels
=
[
"debug"
,
"info"
,
"warning"
,
"error"
];
this
.
logStyles
=
{
debug
:
'INFO'
,
...
...
@@ -576,16 +577,22 @@
if
(
this
.
logLevels
.
indexOf
(
level
)
<
this
.
logLevels
.
indexOf
(
this
.
options
.
logLevel
))
{
return
this
;
// skip logging
}
if
(
this
.
options
.
verbose
)
{
var
levelStr
=
this
.
colorizer
.
colorize
(
'['
+
level
+
']'
,
this
.
logStyles
[
level
]);
this
.
echo
(
levelStr
+
' ['
+
space
+
'] '
+
message
);
// direct output
}
this
.
result
.
log
.
push
({
var
entry
=
{
level
:
level
,
space
:
space
,
message
:
message
,
date
:
new
Date
().
toString
()
});
};
if
(
level
in
this
.
logFormats
&&
isType
(
this
.
logFormats
[
level
],
"function"
))
{
message
=
this
.
logFormats
[
level
](
message
,
level
,
space
);
}
else
{
var
levelStr
=
this
.
colorizer
.
colorize
(
'['
+
level
+
']'
,
this
.
logStyles
[
level
]);
message
=
levelStr
+
' ['
+
space
+
'] '
+
message
;
}
if
(
this
.
options
.
verbose
)
{
this
.
echo
(
message
);
// direct output
}
this
.
result
.
log
.
push
(
entry
);
return
this
;
},
...
...
Please
register
or
sign in
to post a comment