How to debug HyperLedger Composer Transaction code in Playground - hyperledger-composer

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.

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.

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.

Related

Apps Script error: "Exception: Illegal argument" (with no more information): How to find the specific error?

That's it, no more information is given:
The only idea that comes to my mind is adding try-catch in different parts of the code, and with a lot of patience, find it.
Any other better idea?
Source: https://developers.google.com/apps-script/guides/logging#exception_logging
Exception logging
Exception logging sends unhandled exceptions in your script project code to Cloud Logging, along with a stack trace.
To view exception logs, follow the steps below:
Open the Apps Script project.
At the left, click Executions.
At the top, click Add a filter > Status.
Select the Failed and Timed out checkboxes.
You can also view logged exceptions in the GCP console if your script project is using a standard GCP project that you have access to.
To check your project has enabled exception logging:
Open the script project.
At the left, click Project Settings.
Select the Log uncaught exceptions to Cloud Operations checkbox.
Source: https://developers.google.com/apps-script/guides/logging#enable_exception_logging

Can I get the stack trace without an exception/error in Sentry?

Trying to see if I can get the stack trace (for both backend and frontend) on Sentry, without actually creating an error. I don't need to create an event, just sort of fetch whatever the last 50 actions (breadcrumbs, I believe?) were. Any help would be much appreciated!
Using Python for backend.
you can just do a captureMessage instead, but remember to enable the attach_stacktrace mode -> https://docs.sentry.io/platforms/python/configuration/options/#attach-stacktrace

Why when I return back from login to I get an ERROR with the sample app?

This is in regards to the sample: msal-web-sample-0.1.0
I am using tomcat 9 and maven to build and run the msal-web-sample code. It is building fine and running, loading spring, etc. I am able to go out and get a username and passowrd login. However, when it tries to return back to my system (https://localhost:8443/msal4jsample/secure/aad) it just has a bit "ERROR PAGE!" heading with Home Page link going back to the main tomcat page.
In the tomcat runtime it has:
2021-06-29 15:28:06.108 ERROR 6360 --- [io-8443-exec-10] o.s.b.w.servlet.support.ErrorPageFilter : Cannot forward to error page for request [/secure/aad] as the response has already been committed. As a result, the response may have the wrong status code. If your application is running on WebSphere Application Server you may be able to resolve this problem by setting com.ibm.ws.webcontainer.invokeFlushAfterService to false
Of course, that doesn't apply to my setup.
I see the get in the logs returning back OK and don't see any errors on startup. I am at a loss as to where to go from here. Any thoughts?
Also, is there a non-spring implementation that can be used with java but still using MSAL?
Thanks
Alan
Please share additional information about the error. Do you have trouble regrading AAD? Check your environmental settings (Tomcat) if this isn't the case.

How to disable debug logs (app and revel both) in app.conf file of revel framework?

I want to disable debug logs and want other logs to put in a file(logfile). I have tried following two snippets. But it doesnt work as expected.
log.all.filter.module.app = logfile
log.all.filter.module.revel = logfile
log.debug.filter.module.app = off
log.debug.filter.module.revel = off
log.all.output = logfile
log.debug.output = off
Going through the revel log documentation (http://revel.github.io/manual/logging.html), they have mentioned that order of the log is significant but it isnt working in this case it seems. Am i missing something?
I think what you are seeing is debug output from the proxy. When running the revel application from the command line like
revel run myapp
The proxy starts up in debug mode (meaning you will see lots of debug messages), after the application has started the log should be configured to what is set in the app.conf
Also there may be an assumption that off is an active handler, so it would discard the data, unfortunately the handlers are "or"ed logically together, not "and"ed so setting all outputs to one handler then turning one off does not affect the logger set to all

How to log errors when Play Evolutions fail?

I am just getting started with Play Evolutions and I find it pretty tough to figure out why they fail and leave the DB in an inconsistent state.
In Dev mode it will display the error in the default HTML page but it does not say which statement failed. This is also problematic since for this particular application I only have REST APIs that return JSON and so an HTML error is not appropriate. I have my own error handler so I will probably end up matching on ExceptionAttachment and pull out the content/script myself and escape that in the JSON error response. However this is only in DEV mode since I would not want this going back to a real user in PROD.
More frustrating is that it doesn't even log the statement when it fails. I can enable logging for my driver but once the failure has occurred it is too late to then go and enable logging.
Is there anyway to get a more specific error in the logs when an evolution fails?

Resources