1 /* 2 * Conditions Of Use 3 * 4 * This software was developed by employees of the National Institute of 5 * Standards and Technology (NIST), an agency of the Federal Government. 6 * Pursuant to title 15 Untied States Code Section 105, works of NIST 7 * employees are not subject to copyright protection in the United States 8 * and are considered to be in the public domain. As a result, a formal 9 * license is not needed to use the software. 10 * 11 * This software is provided by NIST as a service and is expressly 12 * provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED 13 * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF 14 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT 15 * AND DATA ACCURACY. NIST does not warrant or make any representations 16 * regarding the use of the software or the results thereof, including but 17 * not limited to the correctness, accuracy, reliability or usefulness of 18 * the software. 19 * 20 * Permission to use this software is contingent upon your acceptance 21 * of the terms of this agreement 22 * 23 * . 24 * 25 */ 26 /******************************************************************************* 27 * Product of NIST/ITL Advanced Networking Technologies Division (ANTD) * 28 *******************************************************************************/ 29 package gov.nist.core; 30 31 32 /** 33 * A class to do debug printfs 34 */ 35 public class Debug { 36 37 public static boolean debug = false; 38 public static boolean parserDebug = false; 39 40 static StackLogger stackLogger; 41 setStackLogger(StackLogger stackLogger)42 public static void setStackLogger(StackLogger stackLogger) { 43 Debug.stackLogger = stackLogger; 44 } 45 println(String s)46 public static void println(String s) { 47 if ((parserDebug || debug )&& stackLogger != null ) 48 stackLogger.logDebug(s + "\n"); 49 } printStackTrace(Exception ex)50 public static void printStackTrace(Exception ex) { 51 if ((parserDebug || debug ) && stackLogger != null) { 52 stackLogger.logError("Stack Trace",ex); 53 } 54 } 55 logError(String message, Exception ex)56 public static void logError(String message, Exception ex) { 57 if ((parserDebug || debug) && stackLogger != null ) { 58 stackLogger.logError(message,ex); 59 } 60 } 61 62 } 63