-
Notifications
You must be signed in to change notification settings - Fork 1
Generating ad hoc diagnostic output with Logger
It seems most of the Java source files of tmc-langs contain a Logger instance. For example, Main.java
has the following line:
private static final Logger logger = LoggerFactory.getLogger(Main.class);
Adding lines to the source code that make use of the Logger instance to output messages can be quite useful in figuring out the inner workings of tmc-langs. For example, one could add the following line to the beginning of the main()
function in Main.java
:
logger.info( "XYZ: This is the beginning of the end" );
After rebuilding tmc-langs try running java -jar "$CLI_JAR" help | grep XYZ
.
I added a few Logger lines to some of the source files of tmc-langs and then did run-tests
on the make-based "Hello world" project discussed previously. I found this lamer-compliant approach to understanding how tmc-langs and tmc-langs-make work quite helpful. Here's the command and its output:
henrik@nterror:~/tmc/Week0/0_0_helloworld$ java -jar "$CLI_JAR" run-tests --exercisePath . --outputPath results.txt | grep XYZ
2017-10-01 21:57:40 [main] INFO Main:84 - XYZ: This is the beginning of the end
2017-10-01 21:57:40 [main] INFO Main:276 - XYZ: Entering runTests()
2017-10-01 21:57:40 [main] INFO TaskExecutorImpl:39 - XYZ: Entering runTests()
2017-10-01 21:57:40 [main] INFO MakePlugin:74 - XYZ: Entering the constructor of the MakePlugin class
2017-10-01 21:57:40 [main] INFO ProjectType:48 - XYZ: Entering getProjectType()
2017-10-01 21:57:40 [main] INFO ProjectType:49 - XYZ: Finding plugin for .
2017-10-01 21:57:40 [main] INFO ProjectType:53 - XYZ: Detected project as make
2017-10-01 21:57:40 [main] INFO MakePlugin:164 - XYZ: Entering runTests()
2017-10-01 21:57:40 [main] INFO MakePlugin:213 - XYZ: Entering private runTests()
2017-10-01 21:57:40 [main] INFO MakePlugin:213 - XYZ: Entering private runTests()
2017-10-01 21:57:40 [main] INFO Main:295 - XYZ: Exiting runTests()
2017-10-01 21:57:40 [main] INFO Main:105 - XYZ: This is the end of all things
Obviously this trace of execution is quite coarse and sketchy.