Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Commit ee327ea

Browse files
authored
[Master] New event handler for hlfv1 connector (#4477)
contributes to #4461 Signed-off-by: Dave Kelsey <d_kelsey@uk.ibm.com>
1 parent df3ae47 commit ee327ea

File tree

11 files changed

+829
-470
lines changed

11 files changed

+829
-470
lines changed

packages/composer-common/lib/log/logger.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ const _logLevelAsString = {
7070

7171
// If composer[debug]:acls is provided, the debug level of trace will be used for specified string.
7272
const PROFILES = {
73-
'acls' : ['composer[#]:AccessController']
73+
'acls' : ['composer[#]:AccessController'],
74+
'hlfv1': ['composer[#]:HLFConnectionManager','composer[#]:HLFConnection',
75+
'composer[#]:HLFQueryHandler', 'composer[#]:HLFTxEventHandler']
7476
};
7577

7678
/**
@@ -304,7 +306,7 @@ class Logger {
304306
*
305307
* @param {String} method calling method
306308
* @param {String} msg Text Message
307-
* @param {TransactionID} txId The node-sdk transaction id
309+
* @param {TransactionID} txId The node-sdk transaction id or null if no txid
308310
* @param {Date} startTime Date object representing the start of the timed block
309311
*
310312
* @private
@@ -314,7 +316,11 @@ class Logger {
314316
return;
315317
}
316318
const timeTaken = (Date.now() - startTime).toFixed(2);
317-
this.intlog('verbose', method, `[${txId.getTransactionID().substring(0, 8)}] ${msg} ${timeTaken}ms`);
319+
if (txId && txId.getTransactionID) {
320+
this.intlog('verbose', method, `[${txId.getTransactionID().substring(0, 8)}] ${msg} ${timeTaken}ms`);
321+
} else {
322+
this.intlog('verbose', method, `[NO TXID ] ${msg} ${timeTaken}ms`);
323+
}
318324
}
319325

320326
/**

packages/composer-common/lib/log/winstonInjector.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ exports.getLogger = function (config){
6262
colorize: true,
6363
label: PRODUCT_LABEL,
6464
silent: (consoleLevel===null),
65+
timestamp: timestampFn,
66+
formatter: formatterFn,
6567
level: consoleLevel
6668
};
6769

packages/composer-common/test/log/logger.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,12 @@ describe('Logger', () => {
288288
sinon.assert.calledWith(logger.intlog, 'verbose', 'Method', sinon.match.string);
289289
});
290290

291+
it('perf method should call verbose level and work without a txid, no args', () => {
292+
logger.perf('Method', 'Perf message', null, new Date());
293+
sinon.assert.calledOnce(logger.intlog);
294+
sinon.assert.calledWith(logger.intlog, 'verbose', 'Method', sinon.match.string);
295+
});
296+
291297
it('error method should call error level, no args', () => {
292298
logger.error('Method', 'Message', 'Data');
293299
sinon.assert.calledOnce(logger.intlog);

0 commit comments

Comments
 (0)