コード例 #1
0
ファイル: PerformanceProbe.java プロジェクト: otrack/Batelier
    //
    // Runnable interface
    //
    public void run() {

      // output all active probes
      for (PerformanceProbe probe : list(ALL_RECORDERS)) {
        probe.output("F");
      }

      // close output if not standard output
      if (!outputStream.equals(System.out)) {
        outputStream.close();
      }
    }
コード例 #2
0
ファイル: PerformanceProbe.java プロジェクト: otrack/Batelier
  /**
   * Changes the output of all probes to the specified file. This method may be called multiple
   * times during the execution of the JVM.
   *
   * @param pathname the pathname of the output file.
   */
  public static void setOutput(String pathname) {

    // open specified file
    PrintStream previous = outputStream;
    try {
      outputStream = new PrintStream(new FileOutputStream(pathname));
    } catch (FileNotFoundException e) {
      // if file cannot be opened, output remains unchanged
      return;
    }

    // close previous output if not standard output
    if (previous != null && !previous.equals(System.out)) {
      previous.close();
    }

    // print date and time
    Format format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
    outputStream.println("Starting on " + format.format(new Date()));
  }