GrxDebugUtil.java
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
00003  * All rights reserved. This program is made available under the terms of the
00004  * Eclipse Public License v1.0 which accompanies this distribution, and is
00005  * available at http://www.eclipse.org/legal/epl-v10.html
00006  * Contributors:
00007  * General Robotix Inc.
00008  * National Institute of Advanced Industrial Science and Technology (AIST) 
00009  */
00010 /*
00011  *  GrxDebugUtil.java
00012  *
00013  *  Copyright (C) 2007 GeneralRobotix, Inc.
00014  *  All Rights Reserved
00015  *
00016  *  @author Yuichiro Kawasumi (General Robotix, Inc.)
00017  *  2004/04/19
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 }


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Apr 11 2019 03:30:16