Write log messages with lower levels to the log file.

This commit is contained in:
Minecrell 2014-06-24 20:04:46 +02:00 committed by md_5
parent 4cc009a9c0
commit a668da76d0
2 changed files with 7 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package net.md_5.bungee.log;
import java.io.IOException; import java.io.IOException;
import java.util.logging.FileHandler; import java.util.logging.FileHandler;
import java.util.logging.Formatter; import java.util.logging.Formatter;
import java.util.logging.Level;
import java.util.logging.LogRecord; import java.util.logging.LogRecord;
import java.util.logging.Logger; import java.util.logging.Logger;
import net.md_5.bungee.BungeeCord; import net.md_5.bungee.BungeeCord;
@ -16,6 +17,7 @@ public class BungeeLogger extends Logger
public BungeeLogger(BungeeCord bungee) public BungeeLogger(BungeeCord bungee)
{ {
super( "BungeeCord", null ); super( "BungeeCord", null );
setLevel( Level.ALL );
try try
{ {
@ -24,6 +26,7 @@ public class BungeeLogger extends Logger
addHandler( fileHandler ); addHandler( fileHandler );
ColouredWriter consoleHandler = new ColouredWriter( bungee.getConsoleReader() ); ColouredWriter consoleHandler = new ColouredWriter( bungee.getConsoleReader() );
consoleHandler.setLevel( Level.INFO );
consoleHandler.setFormatter( formatter ); consoleHandler.setFormatter( formatter );
addHandler( consoleHandler ); addHandler( consoleHandler );
} catch ( IOException ex ) } catch ( IOException ex )

View File

@ -62,9 +62,12 @@ public class ColouredWriter extends Handler
@Override @Override
public void publish(LogRecord record) public void publish(LogRecord record)
{
if ( isLoggable( record ) )
{ {
print( getFormatter().format( record ) ); print( getFormatter().format( record ) );
} }
}
@Override @Override
public void flush() public void flush()