fabric-contract-api
Advanced tools
Comparing version 1.4.2-snapshot.27 to 1.4.2-snapshot.28
@@ -26,3 +26,3 @@ /* | ||
logger.debug(`Transaction ${target} -> ${propertyKey} params`, paramNames); | ||
logger.debug(`Transaction -> ${propertyKey} params`, paramNames); | ||
@@ -29,0 +29,0 @@ const paramTypes = Reflect.getMetadata('design:paramtypes', target, propertyKey) || []; |
@@ -10,5 +10,5 @@ /* | ||
const loggers = {}; | ||
const MESSAGE = Symbol.for('message'); | ||
const SPLAT = Symbol.for('splat'); | ||
const util = require('util'); | ||
const safeStringify = require('fast-safe-stringify'); | ||
// looks odd, but this is the most efficient way of padding strings in js | ||
@@ -20,10 +20,24 @@ const padding = ' '; | ||
const formatter = name => winston.format.combine( | ||
winston.format.timestamp(), | ||
winston.format.metadata({fillExcept: ['message', 'level', 'timestamp', 'label']}), | ||
winston.format.colorize(), | ||
winston.format.timestamp(), | ||
winston.format.simple(), | ||
winston.format.padLevels(), | ||
winston.format.printf((info) => { | ||
const {timestamp, level} = info; | ||
const str = (`[${name}]` + padding).substring(0, padding.length); | ||
return `${timestamp} ${level} ${str} ${info[MESSAGE]}`; | ||
const {timestamp, level, message} = info; | ||
const str = (`[c-api:${name}]` + padding).substring(0, padding.length); | ||
let out = ''; | ||
if (info[SPLAT]) { | ||
out = info[SPLAT].map(e => { | ||
if (e && e.error) { | ||
if (e.error.stack) { | ||
return e.error.stack; | ||
} else { | ||
return e.error.message; | ||
} | ||
} else { | ||
return safeStringify(e); | ||
} | ||
}); | ||
} | ||
return `${timestamp} ${level} ${str} ${message} ${out} `; | ||
} | ||
@@ -37,3 +51,3 @@ ) | ||
if (!transport) { | ||
transport = new winston.transports.Console({ | ||
transport = new winston.transports.Console({ | ||
handleExceptions: false, | ||
@@ -47,5 +61,5 @@ }); | ||
// there is no hierachy or split of loggers; one for future versions | ||
function createLogger(loglevel, name) { | ||
function createLogger (loglevel, name) { | ||
const logger = new winston.createLogger({ | ||
level:loglevel, | ||
level: loglevel, | ||
format: formatter(name), | ||
@@ -118,7 +132,7 @@ transports: [ | ||
// node warnings about memory leaks. | ||
function firstTime() { | ||
function firstTime () { | ||
if (!loggers._) { | ||
const loglevel = levelMapping(process.env.CORE_CHAINCODE_LOGGING_LEVEL); | ||
loggers._ = new winston.createLogger({ | ||
level:loglevel, | ||
level: loglevel, | ||
format: formatter('_'), | ||
@@ -135,3 +149,3 @@ transports: [ | ||
process.on('unhandledRejection', (reason, p) => { | ||
loggers._.error('Unhandled Rejection reason ' + reason + ' promise ' + util.inspect(p)); | ||
loggers._.error('Unhandled Rejection reason ' + reason + ' promise ' + util.inspect(p)); | ||
}); | ||
@@ -138,0 +152,0 @@ |
{ | ||
"name": "fabric-contract-api", | ||
"version": "1.4.2-snapshot.27", | ||
"version": "1.4.2-snapshot.28", | ||
"tag": "unstable-1.4", | ||
@@ -27,2 +27,3 @@ "description": "A node.js implementation of Hyperledger Fabric chaincode shim, to allow endorsing peers and user-provided chaincodes to communicate with each other", | ||
"class-transformer": "^0.2.2", | ||
"fast-safe-stringify": "^2.0.6", | ||
"get-params": "^0.1.2", | ||
@@ -29,0 +30,0 @@ "reflect-metadata": "^0.1.12", |
@@ -122,3 +122,5 @@ /* | ||
log.debug('hello', {'one':'two'}); | ||
// sinon.assert.calledWith(logSpy,'wibble'); | ||
log.debug('error', {error:new Error()}); | ||
log.debug('error', {error:{message:''}}); | ||
}); | ||
@@ -131,3 +133,3 @@ | ||
log.debug('hello', 'fred'); | ||
// sinon.assert.calledWith(logSpy,'wibble'); | ||
}); | ||
@@ -134,0 +136,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
477350
4489
5
+ Addedfast-safe-stringify@^2.0.6
+ Addedfast-safe-stringify@2.1.1(transitive)