hyperledger / caliper

A blockchain benchmark framework to measure performance of multiple blockchain solutions https://wiki.hyperledger.org/display/caliper
https://hyperledger.github.io/caliper/
Apache License 2.0
650 stars 402 forks source link

logging transaction monitor doesn't work properly #1436

Open davidkel opened 2 years ago

davidkel commented 2 years ago

According to the documentation to get each worker to perform logging all you need to do is add

monitors:
    transaction:
    - module: logging

However if you do that it will fail with

2022.08.08-17:22:00.892 error [caliper] [worker-message-handler]        Error while handling "initialize" message for Worker#1 (57091): TypeError: Cannot read property 'loggerModuleName' of undefined
    at new LoggingTxObserver (/root/caliper-benchmarks/node_modules/@hyperledger/caliper-core/lib/worker/tx-observers/logging-tx-observer.js:34:53)
    at createTxObserver (/root/caliper-benchmarks/node_modules/@hyperledger/caliper-core/lib/worker/tx-observers/logging-tx-observer.js:78:12)
    at new TxObserverDispatch (/root/caliper-benchmarks/node_modules/@hyperledger/caliper-core/lib/worker/tx-observers/tx-observer-dispatch.js:49:35)
    at new CaliperWorker (/root/caliper-benchmarks/node_modules/@hyperledger/caliper-core/lib/worker/caliper-worker.js:44:35)
    at WorkerMessageHandler._handleInitializeMessage (/root/caliper-benchmarks/node_modules/@hyperledger/caliper-core/lib/worker/worker-message-handler.js:186:27)
    at async ProcessMessenger.<anonymous> (/root/caliper-benchmarks/node_modules/@hyperledger/caliper-core/lib/worker/worker-message-handler.js:85:13)

if you just add the options block it will fail in a similar manner but with null instead of undefined

To make it work this will suffice

monitors:
    transaction:
    - module: logging
      options:
        fred: 1

Looking at the code though, this does have options

     */
    constructor(options, messenger, workerIndex) {
        super(messenger, workerIndex);
        let logger = CaliperUtils.getLogger(options.loggerModuleName || 'txInfo');
        this.logFunction = logger[options.messageLevel || 'info'];
    }

which are undocumented

This seems to be an interesting way to enable logging on all workers and the documentation should reflect this

n-elia commented 1 year ago

I just want to point out that this issue is still alive. The documentation page to be fixed is this, under "Logging" section.