Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logkitten improvements #216

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open

Logkitten improvements #216

wants to merge 19 commits into from

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.

.classpath Outdated Show resolved Hide resolved
.project Outdated Show resolved Hide resolved
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.

LogKitten.java Show resolved Hide resolved
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.

3 participants