001package com.ctre.phoenix;
002
003/**
004 * Object to handle error logging
005 */
006public class Logger
007{
008        /**
009         * Logs an entry into the Phoenix DS Error/Logger stream
010         * @param code Error code to log.  If OKAY is passed, no action is taken.
011         * @param origin Origin string to send to DS/Log
012         * @return OKAY error code.
013         */
014        public static ErrorCode log(ErrorCode code, String origin) {
015                /* only take action if the error code is nonzero */
016                if (code != ErrorCode.OK) {
017                        String stack = java.util.Arrays.toString(Thread.currentThread().getStackTrace());
018                        stack = stack.replaceAll(",", "\n");
019                        int errCode = code.value;
020                        return ErrorCode.valueOf(CTRLoggerJNI.JNI_Logger_Log(errCode, origin, stack));
021                }
022                /* otherwise return OK */
023                return ErrorCode.OK;
024        }
025
026        //public static void close() {
027        //      //CTRLoggerJNI.JNI_Logger_Close();
028        //}
029        //public static void open() {
030        //      //CTRLoggerJNI.JNI_Logger_Open(2);
031        //}
032        /*
033        public static String getVerbose(int code) {
034                return CTRLoggerJNI.JNI_Logger_GetLong(code);
035        }
036        public static String getShort(int code) {
037                return CTRLoggerJNI.JNI_Logger_GetShort(code);
038        }
039        */
040}
041