Skip to content

Conversation

@quialst
Copy link

@quialst quialst commented Feb 10, 2018

Added an instantiable class to LogKitten called Kitten. Kitten can in turn be extended and logged using LogKitten to be able to classify certain errors and log them in different files. Already created and integrated classes include CANKitten for logging CAN errors and messages and RobotKitten for logging based on which robot mode. Global logging is coded into the LogKitten class. MAKE SURE YOU REVIEW THE 2018 CODE PULL REQUEST AS WELL! This new code depends on it.

LogKitten.java Outdated
switch(i.getValue()) {
case "RobotModeKitten":
if(getRobotMode() == ((RobotModeKitten)i.getKey()).getMode()) {
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of duplicate code between "RobotModeKitten" and "CANKitten" cases. The code:

	try {
 		if(i.getKey().output != null) {
 			i.getKey().output.write(content.getBytes());
 		} else {
 			System.out.println("Error logging: " + i.getKey().category + " logfile not open");
		}
 	}
 	catch(IOException ioe) {
 		System.out.println("Error logging " + level.getName() + " message");
 		ioe.printStackTrace();
 	}

Could probably be reduced to a private method, or maybe a better flow could be worked out here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it might be better instead to move the logMessage method to the Kitten class itself, and have LogKitten extend Kitten or something of that sort. Looking at a screen is making me nauseous right now but I can take a closer look tomorrow hopefully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants