Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
19ec27e0
Commit
19ec27e0
authored
May 19, 2018
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix logs so they be compatible with different envs
parent
e9640793
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
88 additions
and
9 deletions
+88
-9
package.json
remix-simulator/package.json
+5
-2
provider.js
remix-simulator/src/provider.js
+1
-2
server.js
remix-simulator/src/server.js
+1
-5
logs.js
remix-simulator/src/utils/logs.js
+81
-0
No files found.
remix-simulator/package.json
View file @
19ec27e0
...
...
@@ -14,12 +14,15 @@
],
"main"
:
"./index.js"
,
"dependencies"
:
{
"ansi-gray"
:
"^0.1.1"
,
"babel-preset-es2017"
:
"^6.24.1"
,
"body-parser"
:
"^1.18.2"
,
"color-support"
:
"^1.1.3"
,
"express"
:
"^4.16.3"
,
"fancy-log"
:
"^1.3.2"
,
"merge"
:
"^1.2.0"
,
"remix-lib"
:
"
latest
"
,
"remix-lib"
:
"
^0.2.5
"
,
"standard"
:
"^10.0.3"
,
"time-stamp"
:
"^2.0.0"
,
"web3"
:
"1.0.0-beta.27"
},
"scripts"
:
{
...
...
remix-simulator/src/provider.js
View file @
19ec27e0
const
log
=
require
(
'
fancy-log
'
)
const
log
=
require
(
'
./utils/logs.js
'
)
const
merge
=
require
(
'merge'
)
const
Accounts
=
require
(
'./methods/accounts.js'
)
...
...
@@ -16,7 +16,6 @@ var Provider = function () {
this
.
methods
=
merge
(
this
.
methods
,
(
new
Misc
()).
methods
())
this
.
methods
=
merge
(
this
.
methods
,
(
new
Transactions
(
this
.
Accounts
.
accounts
)).
methods
())
this
.
methods
=
merge
(
this
.
methods
,
(
new
Whisper
()).
methods
())
log
.
dir
(
this
.
methods
)
}
Provider
.
prototype
.
sendAsync
=
function
(
payload
,
callback
)
{
...
...
remix-simulator/src/server.js
View file @
19ec27e0
...
...
@@ -2,7 +2,7 @@ const express = require('express')
const
bodyParser
=
require
(
'body-parser'
)
const
app
=
express
()
const
Provider
=
require
(
'./provider'
)
const
log
=
require
(
'
fancy-log
'
)
const
log
=
require
(
'
./utils/logs.js
'
)
var
provider
=
new
Provider
()
...
...
@@ -14,14 +14,10 @@ app.get('/', (req, res) => {
})
app
.
use
(
function
(
req
,
res
)
{
// url, body, params, method
log
(
'request '
,
req
.
method
,
req
.
body
)
provider
.
sendAsync
(
req
.
body
,
(
err
,
jsonResponse
)
=>
{
if
(
err
)
{
res
.
send
({
error
:
err
})
}
log
.
dir
(
'response is '
)
log
.
dir
(
jsonResponse
)
res
.
send
(
jsonResponse
)
})
})
...
...
remix-simulator/src/utils/logs.js
0 → 100644
View file @
19ec27e0
'use strict'
;
var
gray
=
require
(
'ansi-gray'
);
var
timestamp
=
require
(
'time-stamp'
);
var
supportsColor
=
require
(
'color-support'
);
function
hasFlag
(
flag
)
{
return
((
typeof
(
process
)
!==
'undefined'
)
&&
(
process
.
argv
.
indexOf
(
'--'
+
flag
)
!==
-
1
));
}
function
addColor
(
str
)
{
if
(
hasFlag
(
'no-color'
))
{
return
str
;
}
if
(
hasFlag
(
'color'
))
{
return
gray
(
str
);
}
if
(
supportsColor
())
{
return
gray
(
str
);
}
return
str
;
}
let
logger
=
{
stdout
:
function
(
arg
)
{
if
(
typeof
(
process
)
===
'undefined'
||
!
process
.
stdout
)
return
;
process
.
stdout
.
write
(
arg
);
},
stderr
:
function
(
arg
)
{
if
(
typeof
(
process
)
===
'undefined'
||
process
.
stderr
)
return
;
process
.
stderr
.
write
(
arg
);
},
};
function
getTimestamp
(){
return
'['
+
addColor
(
timestamp
(
'HH:mm:ss'
))
+
']'
;
}
function
log
(){
var
time
=
getTimestamp
();
logger
.
stdout
(
time
+
' '
);
console
.
log
.
apply
(
console
,
arguments
);
return
this
;
}
function
info
(){
var
time
=
getTimestamp
();
logger
.
stdout
(
time
+
' '
);
console
.
info
.
apply
(
console
,
arguments
);
return
this
;
}
function
dir
(){
var
time
=
getTimestamp
();
logger
.
stdout
(
time
+
' '
);
console
.
dir
.
apply
(
console
,
arguments
);
return
this
;
}
function
warn
(){
var
time
=
getTimestamp
();
logger
.
stderr
(
time
+
' '
);
console
.
warn
.
apply
(
console
,
arguments
);
return
this
;
}
function
error
(){
var
time
=
getTimestamp
();
logger
.
stderr
(
time
+
' '
);
console
.
error
.
apply
(
console
,
arguments
);
return
this
;
}
module
.
exports
=
log
;
module
.
exports
.
info
=
info
;
module
.
exports
.
dir
=
dir
;
module
.
exports
.
warn
=
warn
;
module
.
exports
.
error
=
error
;
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