Esempio n. 1
0
  public static void EndRedirect() {
    rd_flusher.rd_flush(rd_target, rd_buffer);

    rd_target = 0;
    rd_buffer = null;
    rd_buffersize = 0;
    rd_flusher = null;
  }
Esempio n. 2
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
    }
  }