[QUESTION]Best practices for debugging Active-Choices scripts?

1922 views
Skip to first unread message

Ioannis Moutsatsos

unread,
Apr 1, 2017, 7:30:12 AM4/1/17
to BioUno Developers
Recently, I have been dealing with some AC groovy scripts that have proven tough to debug.
The BioUno log (even with v1.5.3) is littered with messages that this or the other AC parameter is missing. Real errors appear as well, embedded in there but in general are hard to find and hard to know exactly what script they originate in (all of them seem to reference Script1)

I also use the javascript console, and in general find it easier to understand where errors originate from as at least for the ones that have fall-back error scripts. For those, you can get the cascaded parameters and substitute into the script outside the build UI for testing.

I'm not sure if I'm doing these things in a very efficient manner. I would like to ask the following questions:
  1. How do I reduce the noise in the BioUno log? Both real errors and those about missing property exceptions seems to be at the same log level.
  2. How do I write debug messages to the BioUno log? (can I use a logger somehow)
  3. Other suggestions from people's experience in debugging while on the build form?
Good suggestions and ideas should go into the Active Choices wiki troubleshooting page.

Thanks and best regards
Ioannis

Bruno P. Kinoshita

unread,
Apr 3, 2017, 1:34:08 AM4/3/17
to biouno-d...@googlegroups.com


Hi Ioannis,

Good questions.

>How
do I reduce the noise in the BioUno log? Both real errors and those
about missing property exceptions seems to be at the same log level.

In
the Java side that may be easier than in the Javascript. Unless you can
pinpoint one specific case, it is hard to confirm we are currently
logging detailed enough information. But if you are able to specify a
use case, the current behaviour, and how we could change it to make it
easier to debug issues; then it must be easier to assess whether that is
doable or not, and how complex it would be.

>How do I write debug messages to the BioUno log? (can I use a logger somehow)

Hummmm. Very interesting. I never thought about that, but you should be able to do that in your scripts.

```
// not tested, but along these lines...

import java.util.logging.Level; import java.util.logging.Logger;

def LOGGER = Logger.getLogger("org.biouno.myscript");
LOGGER.info("Hello");
LOGGER.log(Level.INFO, "Hello", exception);

```

>Other suggestions from people's experience in debugging while on the build form?

For
me the best way to debug problems with plug-ins is still importing the
source code into Eclipse, attaching the debugger and step through a few
parts of the code. It doesn't involve so much Java. Mainly knowing how
to use Maven, an IDE, how and where to put breakpoints, and some of the
Jenkins internal API (which you should be fine as you have been writing
Groovy in Jenkins for a while).

Hope that helps

Bruno


________________________________
From: Ioannis Moutsatsos <imout...@gmail.com>
To: BioUno Developers <biouno-d...@googlegroups.com>
Sent: Sunday, 2 April 2017 12:30 AM
Subject: [QUESTION]Best practices for debugging Active-Choices scripts?



Recently, I have been dealing with some AC groovy scripts that have proven tough to debug.
The BioUno log (even with v1.5.3) is littered with messages that this or the other AC parameter is missing. Real errors appear as well, embedded in there but in general are hard to find and hard to know exactly what script they originate in (all of them seem to reference Script1)

I also use the javascript console, and in general find it easier to understand where errors originate from as at least for the ones that have fall-back error scripts. For those, you can get the cascaded parameters and substitute into the script outside the build UI for testing.

I'm not sure if I'm doing these things in a very efficient manner. I would like to ask the following questions:
1. How do I reduce the noise in the BioUno log? Both real errors and those about missing property exceptions seems to be at the same log level.
2. How do I write debug messages to the BioUno log? (can I use a logger somehow)
3. Other suggestions from people's experience in debugging while on the build form?
Good suggestions and ideas should go into the Active Choices wiki troubleshooting page.

Thanks and best regards
Ioannis
--
You received this message because you are subscribed to the Google Groups "BioUno Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to biouno-develop...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ioannis Moutsatsos

unread,
Apr 3, 2017, 9:58:46 AM4/3/17
to BioUno Developers
Thanks Bruno!

Some feedback on your comments:
Are we currently logging detailed enough information.?
        I think yes, If anything the log is just overwhelming when set to ALL

So my follow-up question is what is the recommended level for logging? 
I'm not sure what to expect from the available settings?

The best way to debug problems with plug-ins is still importing the source code into Eclipse, attaching the debugger and step through a few parts of the code.

           I agree as long as you are working on the plugin itself. 


The debugging I'm doing is not really related to the Active Choices plugin, but rather to the groovy script used to retrieve parameters and such. These scripts can get pretty complex these days. When an exception is thrown in the script I would like to easily identify it in the BioUno log. Also each page could contain >15 Active Choice parameters. How do I easily identify which of the parameter scripts is throwing an exception or what are the run time values of various Jenkins and script parameter/variables.


I will try your suggestion and see if I can write some diagnostic messages to the log.


Your feedback much appreciated. Thanks Bruno!

Ioannis Moutsatsos

unread,
Apr 3, 2017, 10:49:05 AM4/3/17
to BioUno Developers
Hi Bruno;
I've also tried your suggestions about setting up a scpecific logger for the script in question.
That works really well and clearly isolates the log info from your script.

This will help me a great deal!!


On Saturday, April 1, 2017 at 7:30:12 AM UTC-4, Ioannis Moutsatsos wrote:
Reply all
Reply to author
Forward
0 new messages