1

I am using a local install of Playground on MacOS.

I was successful to create my business network, add my model file and logic to this network and create assets and participants instances.

So now I am ready to submit my first transaction, but I get an error message in the popup window as a result to my request. The message per se is not the problem (it's about some Undefined asset), my problem is I want to debug this transaction code by producing some execution traces, using old-school printf or log message.

I tried to insert console.log(message) instructions in my transaction code but eventually I was not able to retrieve those logs traces (eg. using a command like docker logs -f composer).

Is there another way to produce logs traces? Or did I miss a config setting to defilter logs in docker logs?

Any help greatly appreciated!

Olivier.

OlivierD
  • 45
  • 8

2 Answers2

2

On console logging (and seeing them in the browser Developer console), see this Stack Overflow here (hyperledger composer playground) Can you see results of console.log('something') in browser? (it also has a link to more info there

See here https://hyperledger.github.io/composer/latest/problems/diagnostics.html for more on logging / where to find debug logs.

As for setting checkpoint/breakpoints: These are set by the Editor tooling In H/Composer, you can just use the embedded connector (eg such as TP functions) to try out / step through each breakpoint - for more info on VSCode -> https://code.visualstudio.com/docs/editor/debugging and Atom -> How do I set a breakpoint inside of atom's package? and I posted the link to diagnostics/logging above.

Paul O'Mahony
  • 6,740
  • 1
  • 10
  • 15
  • The link to https://hyperledger.github.io/composer/problems/diagnostics.html is broken – ulu Apr 01 '18 at 16:22
  • 1
    try https://hyperledger.github.io/composer/latest/problems/diagnostics.html (we have 'latest' and 'next' now -> https://hyperledger.github.io/composer/next/problems/diagnostics.html ) - have updated the link in the answer above – Paul O'Mahony Apr 04 '18 at 11:28
1

One quick way I used to insert breakpoints with debug messages, is to throw an exception using throw new Error(...) in the transaction method.

This shows up in the playground interface as well.

shinki
  • 43
  • 6