001package net.minecraft.server.gui;
002
003import cpw.mods.fml.relauncher.Side;
004import cpw.mods.fml.relauncher.SideOnly;
005import java.util.logging.Formatter;
006import java.util.logging.Handler;
007import java.util.logging.LogRecord;
008import javax.swing.JTextArea;
009
010@SideOnly(Side.SERVER)
011public class GuiLogOutputHandler extends Handler
012{
013    private int[] field_79023_b = new int[1024];
014    private int field_79024_c = 0;
015    Formatter field_79025_a = new GuiLogFormatter(this);
016    private JTextArea field_79022_d;
017
018    public GuiLogOutputHandler(JTextArea par1JTextArea)
019    {
020        this.setFormatter(this.field_79025_a);
021        this.field_79022_d = par1JTextArea;
022    }
023
024    public void close() {}
025
026    public void flush() {}
027
028    public void publish(LogRecord par1LogRecord)
029    {
030        int i = this.field_79022_d.getDocument().getLength();
031        this.field_79022_d.append(this.field_79025_a.format(par1LogRecord));
032        this.field_79022_d.setCaretPosition(this.field_79022_d.getDocument().getLength());
033        int j = this.field_79022_d.getDocument().getLength() - i;
034
035        if (this.field_79023_b[this.field_79024_c] != 0)
036        {
037            this.field_79022_d.replaceRange("", 0, this.field_79023_b[this.field_79024_c]);
038        }
039
040        this.field_79023_b[this.field_79024_c] = j;
041        this.field_79024_c = (this.field_79024_c + 1) % 1024;
042    }
043}