Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
alvagi
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
alvagi
Commits
5d5b8c13
Commit
5d5b8c13
authored
Nov 25, 2017
by
Sergey Razuvaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added external logger support
parent
6cbea7a1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
8 deletions
+9
-8
context.js
lib/context.js
+8
-7
package.json
package.json
+1
-1
No files found.
lib/context.js
View file @
5d5b8c13
...
@@ -8,14 +8,15 @@ var commands = require('./command');
...
@@ -8,14 +8,15 @@ var commands = require('./command');
var
Context
=
function
(
stream
,
loggerOptions
)
{
var
Context
=
function
(
stream
,
loggerOptions
)
{
EventEmitter
.
call
(
this
);
EventEmitter
.
call
(
this
);
function
consoleDecorator
(
data
){
function
consoleDecorator
(
arrow
,
data
){
return
console
.
log
(
JSON
.
stringify
(
data
))
return
console
.
log
(
arrow
,
JSON
.
stringify
(
data
));
}
}
this
.
log
=
(
loggerOptions
.
logger
)
?
loggerOptions
.
logger
:
consoleDecorator
;
this
.
debug
=
loggerOptions
.
debug
this
.
log
=
loggerOptions
.
logger
.
debug
||
consoleDecorator
;
this
.
debug
=
loggerOptions
.
debug
this
.
stream
=
new
Readable
();
this
.
stream
=
new
Readable
();
this
.
stream
.
setEncoding
(
'
utf8
'
);
this
.
stream
.
setEncoding
(
'
utf8
'
);
this
.
stream
.
wrap
(
stream
);
this
.
stream
.
wrap
(
stream
);
...
@@ -119,11 +120,11 @@ Context.prototype.end = function () {
...
@@ -119,11 +120,11 @@ Context.prototype.end = function () {
};
};
Context
.
prototype
.
sendCommand
=
function
(
command
)
{
Context
.
prototype
.
sendCommand
=
function
(
command
)
{
if
(
this
.
debug
)
this
.
log
({
command
:
command
});
if
(
this
.
debug
)
this
.
log
(
'
------->
'
,
{
command
:
command
});
var
self
=
this
;
var
self
=
this
;
return
new
Promise
(
function
(
resolve
,
reject
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
self
.
send
(
command
+
'
\n
'
,
function
(
err
,
result
)
{
self
.
send
(
command
+
'
\n
'
,
function
(
err
,
result
)
{
if
(
self
.
debug
)
self
.
log
({
err
:
err
,
result
:
result
});
if
(
self
.
debug
)
self
.
log
(
'
<-------
'
,
{
err
:
err
,
result
:
result
});
if
(
err
)
{
if
(
err
)
{
reject
(
err
);
reject
(
err
);
}
else
{
}
else
{
...
...
package.json
View file @
5d5b8c13
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
"author"
:
"Sergey Dmitriev <serge.dmitriev@gmail.com>"
,
"author"
:
"Sergey Dmitriev <serge.dmitriev@gmail.com>"
,
"name"
:
"ding-dong"
,
"name"
:
"ding-dong"
,
"description"
:
"Write AGI-server quickly! (AGI - Asterisk Gateway Interface)"
,
"description"
:
"Write AGI-server quickly! (AGI - Asterisk Gateway Interface)"
,
"version"
:
"0.1.
5
"
,
"version"
:
"0.1.
6
"
,
"repository"
:
{
"repository"
:
{
"type"
:
"git"
,
"type"
:
"git"
,
"url"
:
"git://github.com/antirek/ding-dong.git"
"url"
:
"git://github.com/antirek/ding-dong.git"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment