GrxDebugUtil.java
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
3  * All rights reserved. This program is made available under the terms of the
4  * Eclipse Public License v1.0 which accompanies this distribution, and is
5  * available at http://www.eclipse.org/legal/epl-v10.html
6  * Contributors:
7  * General Robotix Inc.
8  * National Institute of Advanced Industrial Science and Technology (AIST)
9  */
10 /*
11  * GrxDebugUtil.java
12  *
13  * Copyright (C) 2007 GeneralRobotix, Inc.
14  * All Rights Reserved
15  *
16  * @author Yuichiro Kawasumi (General Robotix, Inc.)
17  * 2004/04/19
18  */
19 package com.generalrobotix.ui.util;
20 
21 import java.io.FileOutputStream;
22 import java.io.OutputStreamWriter;
23 import java.util.logging.*;
24 
25 public class GrxDebugUtil {
26  private static boolean isDebugging_ = false;
27 
28  public static void setDebugFlag(boolean flag){
29  isDebugging_ = flag;
30  Logger logger = Logger.getLogger("");
31  if (flag) {
32  System.out.println("debug on (message logging level : INFO)");
33  logger.setLevel(Level.INFO);
34  } else {
35  System.out.println("message logging level : SEVERE");
36  logger.setLevel(Level.SEVERE);
37  }
38  }
39 
40  public static void print(String s){
41  if (isDebugging_ == true)
42  System.out.print(s);
43  }
44 
45  public static void println(String s){
46  if (isDebugging_ == true)
47  System.out.println(s);
48  }
49 
50  public static void printErr(String s) {
51  if (isDebugging_ == true)
52  System.err.println(s);
53  }
54 
55  public static void printErr(String s,Exception e) {
56  if (isDebugging_ == true){
57  System.err.println(s);
58  e.printStackTrace();
59  }
60  }
61 
62  public static void outputLogFile(String path, String s , boolean bAppend){
63  try {
64  FileOutputStream logFileStream = new FileOutputStream(path, bAppend);
65  OutputStreamWriter logFileOut = new OutputStreamWriter(logFileStream, "UTF-8");
66  logFileOut.write(s + "\n");
67  logFileOut.flush();
68  logFileOut.close();
69  } catch (Exception e){
70  GrxDebugUtil.printErr("GrxDebugUtil.outputLogFile: ", e);
71  }
72  }
73 
74  public static void outputLogFile(String path, String s){
75  GrxDebugUtil.outputLogFile(path, s, true);
76  }
77 
78  public static boolean isDebugging() {
79  return isDebugging_;
80  }
81 }
static void outputLogFile(String path, String s, boolean bAppend)
static void setDebugFlag(boolean flag)
static void printErr(String s, Exception e)
::OutPortBase::Logger logger
png_infop png_uint_32 flag
Definition: png.h:2159
static void outputLogFile(String path, String s)


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Sep 8 2022 02:24:03