Skip to content

Commit 04cec1c

Browse files
committed
new class JythonDev: handles debugging level for printing messages and errors.
1 parent 7f00a1a commit 04cec1c

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package org.scijava.plugins.scripteditor.jython;
2+
3+
public class JythonDev
4+
{
5+
static public int SILENT = 0,
6+
MESSAGES = 1,
7+
ERRORS = 2;
8+
9+
/** Adjust value to see debugging information, including:
10+
* SILENT: nothing is printed at all.
11+
* MESSAGES: prints light messages indicating some internals and the kinds of errors.
12+
* ERRORS: prints everything including exceptions.
13+
*/
14+
static public int debug = MESSAGES;
15+
16+
static public final void print(Object s) {
17+
if (debug >= MESSAGES) System.out.println(s);
18+
}
19+
20+
static public final void printError(Throwable e) {
21+
if (debug >= ERRORS) e.printStackTrace();
22+
}
23+
24+
static public final void printTrace(Object s) {
25+
if (debug >= ERRORS) System.out.println(s);
26+
}
27+
28+
static public final void print(Object s, Throwable e) {
29+
if (debug >= ERRORS) {
30+
System.out.println(s);
31+
e.printStackTrace();
32+
} else if (debug >= MESSAGES) {
33+
System.out.println(s.toString() + " :: " + e.getMessage());
34+
}
35+
}
36+
37+
}

0 commit comments

Comments
 (0)