-
Notifications
You must be signed in to change notification settings - Fork 0
Logging
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.