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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.class

.classpath
.project
# Mobile Tools for Java (J2ME)
.mtj.tmp/

Expand Down
16 changes: 16 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<projectDescription>
<name>standard</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
55 changes: 55 additions & 0 deletions CANKitten.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package org.usfirst.frc4904.standard;

public class CANKitten extends Kitten {
public CANKitten(String category) {
super(category);
}

public static void logCAN(char kittenLevel, String message) {
switch(kittenLevel) {
case 'f':
LogKitten.f(message);
break;
case 'e':
LogKitten.e(message);
break;
case 'w':
LogKitten.w(message);
break;
case 'v':
LogKitten.v(message);
break;
case 'd':
LogKitten.d(message);
break;
}
}

public static void logCAN(char kittenLevel, String message, Boolean override) {
switch(kittenLevel) {
case 'f':
LogKitten.f(message, override);
break;
case 'e':
LogKitten.e(message, override);
break;
case 'w':
LogKitten.w(message, override);
break;
case 'v':
LogKitten.v(message, override);
break;
case 'd':
LogKitten.d(message, override);
break;
}
}

public static void logCANError(Exception ex) {
LogKitten.ex(ex);
}

public static void logCANError(Exception ex, Boolean override) {
LogKitten.ex(ex, override);
}
}
46 changes: 46 additions & 0 deletions Kitten.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.usfirst.frc4904.standard;

import java.io.BufferedOutputStream;
import org.usfirst.frc4904.standard.LogKitten;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Kitten {
protected final static String LOG_PATH = LogKitten.getLogPath();
public String category;
public BufferedOutputStream output;
public String generalPath;
public File pathDirectory;
public String specificPath;
public String specificAliasPath;
public File logger;
public File loggerAlias;
private static final SimpleDateFormat TIMESTAMP_FORMAT = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");
protected volatile boolean mute;

public Kitten(String category) {
this.category = category;
this.generalPath = Kitten.LOG_PATH + this.category;
this.pathDirectory = new File(this.generalPath);
this.specificPath = this.generalPath + timestamp() + ".log";
this.logger = new File(this.specificPath);
this.specificAliasPath = this.specificPath + "recent.log";
this.loggerAlias = new File(this.specificAliasPath);
this.mute = false;
}

public boolean getMute() {
return this.getMute();
}

public void setMute(boolean mute) {
this.mute = mute;
}

public synchronized String timestamp() {
return TIMESTAMP_FORMAT.format(new Date());
}


}
Loading