added ignore to Logger interface

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2104 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2010-07-12 08:44:52 +00:00
parent c018491a36
commit 608eec242e
6 changed files with 42 additions and 0 deletions

View File

@ -114,6 +114,14 @@ public class JavaUtilLog implements Logger
return new JavaUtilLog(name);
}
public void ignore(Throwable ignored)
{
if (Log.isIgnored())
{
warn(Log.IGNORED, ignored);
}
}
private String format(String msg, Object... args)
{
msg = String.valueOf(msg); // Avoids NPE

View File

@ -116,6 +116,10 @@ public class Log
return __log;
}
static boolean isIgnored()
{
return __ignored;
}
/**
* Set Log to parent Logger.

View File

@ -99,4 +99,10 @@ public interface Logger
* @return a logger with the given name
*/
public Logger getLogger(String name);
/**
* Ignore an exception.
* <p>This should be used rather than an empty catch block.
*/
public void ignore(Throwable ignored);
}

View File

@ -181,6 +181,14 @@ public class LoggerLog implements Logger
}
}
public void ignore(Throwable ignored)
{
if (Log.isIgnored())
{
warn(Log.IGNORED, ignored);
}
}
public Logger getLogger(String name)
{
try

View File

@ -95,6 +95,14 @@ public class Slf4jLog implements Logger
return new Slf4jLog(name);
}
public void ignore(Throwable ignored)
{
if (Log.isIgnored())
{
warn(Log.IGNORED, ignored);
}
}
@Override
public String toString()
{

View File

@ -325,4 +325,12 @@ public class StdErrLog implements Logger
{
return "StdErrLog:" + _name + ":DEBUG=" + _debug;
}
public void ignore(Throwable ignored)
{
if (Log.isIgnored())
{
warn(Log.IGNORED, ignored);
}
}
}