add walletId and copayerId to log
This commit is contained in:
parent
5b4e69ef9c
commit
ac5af8ed73
|
@ -56,11 +56,18 @@ ExpressApp.prototype.start = function(opts, cb) {
|
||||||
if (opts.disableLogs) {
|
if (opts.disableLogs) {
|
||||||
log.level = 'silent';
|
log.level = 'silent';
|
||||||
} else {
|
} else {
|
||||||
// TODO access.log
|
var morgan = require('morgan');
|
||||||
//var accessLogStream = fs.createWriteStream(__dirname + '/access.log', {flags: 'a'})
|
morgan.token('walletId', function getId(req) {
|
||||||
//app.use(morgan('combined', {stream: accessLogStream}))
|
return req.walletId
|
||||||
// app.use(require('morgan')('dev'));
|
});
|
||||||
this.app.use(require('morgan')(':remote-addr :date[iso] ":method :url" :status :res[content-length] :response-time ":user-agent" '));
|
|
||||||
|
morgan.token('copayerId', function getId(req) {
|
||||||
|
return req.copayerId
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
this.app.use(morgan(' :remote-addr :date[iso] ":method :url" :status :res[content-length] :response-time ":user-agent" :walletId :copayerId'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -127,6 +134,11 @@ ExpressApp.prototype.start = function(opts, cb) {
|
||||||
};
|
};
|
||||||
WalletService.getInstanceWithAuth(auth, function(err, server) {
|
WalletService.getInstanceWithAuth(auth, function(err, server) {
|
||||||
if (err) return returnError(err, res, req);
|
if (err) return returnError(err, res, req);
|
||||||
|
|
||||||
|
// For logging
|
||||||
|
req.walletId = server.walletId;
|
||||||
|
req.copayerId = server.copayerId;
|
||||||
|
|
||||||
return cb(server);
|
return cb(server);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -200,6 +212,7 @@ ExpressApp.prototype.start = function(opts, cb) {
|
||||||
getServerWithAuth(req, res, function(server) {
|
getServerWithAuth(req, res, function(server) {
|
||||||
var opts = {};
|
var opts = {};
|
||||||
if (req.query.includeExtendedInfo == '1') opts.includeExtendedInfo = true;
|
if (req.query.includeExtendedInfo == '1') opts.includeExtendedInfo = true;
|
||||||
|
|
||||||
server.getStatus(opts, function(err, status) {
|
server.getStatus(opts, function(err, status) {
|
||||||
if (err) return returnError(err, res, req);
|
if (err) return returnError(err, res, req);
|
||||||
res.json(status);
|
res.json(status);
|
||||||
|
|
Loading…
Reference in New Issue