Wiki

Clone wiki

javarosa / SystemOut

System Out Calls in !JavaRosa

In order to maintain console output as a meaningful tool for different levels of development (Debugging, Deployed code, etc) any code in !JavaRosa's libraries that makes a call to System.out or System.err should be wrapped inside of a pre-processing directive. The variable we use to signal output level is "debug.output", which can be set in the build.properties file.

This system is very much open to improvement and discussion among the community. It was conceived and implemented quickly in order to solve specific problems.

debug.output can currently be one of three different states.

  • verbose - Used for generally helpful (but not wasteful) output, such as "Expected but not strictly necessary attribute FOO not found in parse"
  • exception - Used to display information about exceptions that have occurred in the code
  • anything else - Used to suppress intentional output for the purposes of displaying test output, or to not waste resources on devices where a console isn't available.

As an example, an exception could display its output in the following manner. The following call only displays the e.printStackTrace() text if debug.output is verbose or exception. If the text wasn't an exception, only the verbose flag should be used.

    catch(IllegalArgumentException e){
        //#if debug.output==verbose || debug.output==exception
	e.printStackTrace();
	//#endif
    }

Updated