Skip to content
This repository has been archived by the owner on Jul 29, 2020. It is now read-only.

Logging

Finn edited this page May 21, 2018 · 1 revision

In the BitBrawl competition, we disallow you from using System.out because we use stdout to communicate with the game engine. Instead, you should log messages using the provided logger. The logger is provided with the JavaController.getLogger method. This means that if you're logging from within your main Controller class, logging is as simple as calling getLogger().info("Hello, World!")

You can also feel free to use the other logging methods to indicate a problem, like getLogger().warning("Uh oh"). If you want to log an exception, you can use the log(Level, String, Throwable) method, as in:

try {
	doSomething();
} catch (IllegalStateException e) {
	getLogger().log(Level.WARNING, "Unable to do something", e);
}

You can also use the version of log that lets you print objects, as in getLogger().log(Level.INFO, "My location is {0}", player.getLocation()).

Note that logging from another class may be more difficult. You would have to pass the logger object to the other class in some way.