예제 #1
0
  /** Prints out messages, which can also be redirected to a remote client. */
  public static void Printf(String fmt, Vargs vargs) {
    String msg = sprintf(_debugContext + fmt, vargs);
    if (rd_target != 0) {
      if ((msg.length() + rd_buffer.length()) > (rd_buffersize - 1)) {
        rd_flusher.rd_flush(rd_target, rd_buffer);
        rd_buffer.setLength(0);
      }
      rd_buffer.append(msg);
      return;
    }

    Console.Print(msg);

    // also echo to debugging console
    Sys.ConsoleOutput(msg);

    // logfile
    if (Globals.logfile_active != null && Globals.logfile_active.value != 0) {
      String name;

      if (Globals.logfile == null) {
        name = QuakeFileSystem.Gamedir() + "/qconsole.log";
        if (Globals.logfile_active.value > 2)
          try {
            Globals.logfile = new RandomAccessFile(name, "rw");
            Globals.logfile.seek(Globals.logfile.length());
          } catch (Exception e) {
            // TODO: do quake2 error handling!
            e.printStackTrace();
          }
        else
          try {
            Globals.logfile = new RandomAccessFile(name, "rw");
          } catch (FileNotFoundException e1) {
            // TODO: do quake2 error handling!
            e1.printStackTrace();
          }
      }
      if (Globals.logfile != null)
        try {
          Globals.logfile.writeChars(msg);
        } catch (IOException e) {
          // TODO: do quake2 error handling!
          e.printStackTrace();
        }
      if (Globals.logfile_active.value > 1) ; // do nothing
      // fflush (logfile);		// force it to save every time
    }
  }
예제 #2
0
  public static void BeginRedirect(
      int target, StringBuffer buffer, int buffersize, RD_Flusher flush) {
    if (0 == target || null == buffer || 0 == buffersize || null == flush) return;

    rd_target = target;
    rd_buffer = buffer;
    rd_buffersize = buffersize;
    rd_flusher = flush;

    rd_buffer.setLength(0);
  }