Skip to content

Logging

Joel Gallant edited this page Jun 19, 2013 · 1 revision

The logging framework

Logging is not especially difficult in ATALibJ. In fact, there is an entire framework designed to make it as easy and flexible as possible. It all starts at the Logger class. Loggers are statically accessible, using the getLogger(Class) and getLogger(Object).

To log anywhere, you need a Logger instance. Logger instances let you log messages at different logging levels. The levels are differentiated by their respective methods. The getLogger(Class) method takes the current Logger instance that is associated with the class. If there has never been a Logger created, it is created and returned. Whenever the same class is given, the same logger is returned. Different classes return different loggers. This is dependent on the class's hashcode.

The getLogger(Object) method returns a logger that is associated with the class of the object given. For example, if you were to run

getLogger(new Integer(13))

It would be equivalent to

getLogger(Integer.class)

Sometimes, you want to log things to custom outputs. This method lets you do that. A Log object outputs strings somewhere. To output to a file, use FileLog

If you want the Log object to be added to every Logger, use addLogToAll(Log).

*Note: A console log is added to every Logger object by default - you don't need to!

#Logging levels

###Debug Debugging logs will send a message to all Log objects, indicating that it is a debug message.

###Info Info logs will send a message to all Log objects, indicating that it is a info message.

###Warn Warning logs will send a message to all Log objects, indicating that it is a warn message. It will also send the message to the driverstation LCD screen.

###Error Error logs will send a message to all Log objects, indicating that it is a error message. It will also send the message to the driverstation LCD screen. Errors print a stack trace to the console.

###Fatal Error logs will send a message to all Log objects, indicating that it is a error message. It will also send the message to the driverstation LCD screen. Errors print a stack trace to the console. The entire program will exit when a fatal log is sent. Returns error code 8001.

##displayLCDMessage(String) This method will send the message directly to the DriverStationLCD on the line below the last logged line.

Clone this wiki locally