Squashed 'third_party/Phoenix-frc-lib/' content from commit 666d176
Change-Id: Ibaca2fc8ffb1177e786576cc1e4cc9f7a8c98f13
git-subtree-dir: third_party/Phoenix-frc-lib
git-subtree-split: 666d176a08151793044ab74e0005f13d3732ed96
diff --git a/java/src/com/ctre/phoenix/Logger.java b/java/src/com/ctre/phoenix/Logger.java
new file mode 100644
index 0000000..c1caaca
--- /dev/null
+++ b/java/src/com/ctre/phoenix/Logger.java
@@ -0,0 +1,38 @@
+package com.ctre.phoenix;
+
+public class Logger
+{
+ /**
+ * Logs an entry into the Phoenix DS Error/Logger stream
+ * @param code Error code to log. If OKAY is passed, no action is taken.
+ * @param origin Origin string to send to DS/Log
+ * @return OKAY error code.
+ */
+ public static ErrorCode log(ErrorCode code, String origin) {
+ /* only take action if the error code is nonzero */
+ if (code != ErrorCode.OK) {
+ String stack = java.util.Arrays.toString(Thread.currentThread().getStackTrace());
+ stack = stack.replaceAll(",", "\n");
+ int errCode = code.value;
+ return ErrorCode.valueOf(CTRLoggerJNI.JNI_Logger_Log(errCode, origin, stack));
+ }
+ /* otherwise return OK */
+ return ErrorCode.OK;
+ }
+
+ //public static void close() {
+ // //CTRLoggerJNI.JNI_Logger_Close();
+ //}
+ //public static void open() {
+ // //CTRLoggerJNI.JNI_Logger_Open(2);
+ //}
+ /*
+ public static String getVerbose(int code) {
+ return CTRLoggerJNI.JNI_Logger_GetLong(code);
+ }
+ public static String getShort(int code) {
+ return CTRLoggerJNI.JNI_Logger_GetShort(code);
+ }
+ */
+}
+