Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 package com.generalrobotix.ui.util;
00020
00021 import java.io.FileOutputStream;
00022 import java.io.OutputStreamWriter;
00023 import java.util.logging.*;
00024
00025 public class GrxDebugUtil {
00026 private static boolean isDebugging_ = false;
00027
00028 public static void setDebugFlag(boolean flag){
00029 isDebugging_ = flag;
00030 Logger logger = Logger.getLogger("");
00031 if (flag) {
00032 System.out.println("debug on (message logging level : INFO)");
00033 logger.setLevel(Level.INFO);
00034 } else {
00035 System.out.println("message logging level : SEVERE");
00036 logger.setLevel(Level.SEVERE);
00037 }
00038 }
00039
00040 public static void print(String s){
00041 if (isDebugging_ == true)
00042 System.out.print(s);
00043 }
00044
00045 public static void println(String s){
00046 if (isDebugging_ == true)
00047 System.out.println(s);
00048 }
00049
00050 public static void printErr(String s) {
00051 if (isDebugging_ == true)
00052 System.err.println(s);
00053 }
00054
00055 public static void printErr(String s,Exception e) {
00056 if (isDebugging_ == true){
00057 System.err.println(s);
00058 e.printStackTrace();
00059 }
00060 }
00061
00062 public static void outputLogFile(String path, String s , boolean bAppend){
00063 try {
00064 FileOutputStream logFileStream = new FileOutputStream(path, bAppend);
00065 OutputStreamWriter logFileOut = new OutputStreamWriter(logFileStream, "UTF-8");
00066 logFileOut.write(s + "\n");
00067 logFileOut.flush();
00068 logFileOut.close();
00069 } catch (Exception e){
00070 GrxDebugUtil.printErr("GrxDebugUtil.outputLogFile: ", e);
00071 }
00072 }
00073
00074 public static void outputLogFile(String path, String s){
00075 GrxDebugUtil.outputLogFile(path, s, true);
00076 }
00077
00078 public static boolean isDebugging() {
00079 return isDebugging_;
00080 }
00081 }