[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v_0.9.21-15-gcf03337
added by portage for gitosis-gentoo
git-noreply at pixie.qos.ch
Thu Jun 17 23:44:43 CEST 2010
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".
The branch, master has been updated
via cf03337b10f4d987ffa47d00a904e2565b8975a9 (commit)
from 263b38aad03194fc0ec2c1b91ca8c99c885d1404 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=cf03337b10f4d987ffa47d00a904e2565b8975a9
http://github.com/ceki/logback/commit/cf03337b10f4d987ffa47d00a904e2565b8975a9
commit cf03337b10f4d987ffa47d00a904e2565b8975a9
Author: Ceki Gulcu <ceki at qos.ch>
Date: Thu Jun 17 23:38:58 2010 +0200
- ch.logback.core.pattern.Converter write() method changed the first
parameter from StringBuffer to StringBuilder. Since converters do not
override this method, the change should not effect users with custom
converters.
- Added support for logback.groovy reload in ReconfigureOnChangeFilter
diff --git a/logback-access/src/main/java/ch/qos/logback/access/html/HTMLLayout.java b/logback-access/src/main/java/ch/qos/logback/access/html/HTMLLayout.java
index e876b75..51b6fa4 100644
--- a/logback-access/src/main/java/ch/qos/logback/access/html/HTMLLayout.java
+++ b/logback-access/src/main/java/ch/qos/logback/access/html/HTMLLayout.java
@@ -92,7 +92,7 @@ public class HTMLLayout extends HTMLLayoutBase<AccessEvent> {
buf.append("<td class=\"");
buf.append(computeConverterName(c));
buf.append("\">");
- buf.append(c.convert(event));
+ c.write(buf, event);
buf.append("</td>");
buf.append(LINE_SEPARATOR);
}
diff --git a/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/GafferConfigurator.groovy b/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/GafferConfigurator.groovy
index ffd99cb..162df73 100644
--- a/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/GafferConfigurator.groovy
+++ b/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/GafferConfigurator.groovy
@@ -36,6 +36,11 @@ class GafferConfigurator {
run(url.text);
}
+ void run(File file) {
+ informContextOfURLUsedForConfiguration(file.toURI().toURL());
+ run(file.text);
+ }
+
void run(String dslText) {
Binding binding = new Binding();
binding.setProperty("hostname", ContextUtil.getLocalHostName());
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/html/HTMLLayout.java b/logback-classic/src/main/java/ch/qos/logback/classic/html/HTMLLayout.java
index 9152f46..17e8b79 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/html/HTMLLayout.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/html/HTMLLayout.java
@@ -112,7 +112,7 @@ public class HTMLLayout extends HTMLLayoutBase<ILoggingEvent> {
buf.append("<td class=\"");
buf.append(computeConverterName(c));
buf.append("\">");
- buf.append(c.convert(event));
+ c.write(buf, event);
buf.append("</td>");
buf.append(LINE_SEPARATOR);
}
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeFilter.java b/logback-classic/src/main/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeFilter.java
index cd04f93..8aee404 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeFilter.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeFilter.java
@@ -17,6 +17,10 @@ import java.io.File;
import java.net.URL;
import java.net.URLDecoder;
+import ch.qos.logback.classic.gaffer.GafferConfigurator;
+import ch.qos.logback.classic.util.EnvUtil;
+import ch.qos.logback.core.status.ErrorStatus;
+import ch.qos.logback.core.status.StatusManager;
import org.slf4j.Marker;
import ch.qos.logback.classic.Level;
@@ -30,9 +34,8 @@ import ch.qos.logback.core.status.InfoStatus;
/**
* Reconfigure a LoggerContext when the configuration file changes.
- *
+ *
* @author Ceki Gulcu
- *
*/
public class ReconfigureOnChangeFilter extends TurboFilter {
@@ -55,14 +58,14 @@ public class ReconfigureOnChangeFilter extends TurboFilter {
@Override
public void start() {
URL url = (URL) context
- .getObject(CoreConstants.URL_OF_LAST_CONFIGURATION_VIA_JORAN);
+ .getObject(CoreConstants.URL_OF_LAST_CONFIGURATION_VIA_JORAN);
if (url != null) {
fileToScan = convertToFile(url);
if (fileToScan != null) {
synchronized (lock) {
long inSeconds = refreshPeriod / 1000;
addInfo("Will scan for changes in file [" + fileToScan + "] every "
- + inSeconds + " seconds. ");
+ + inSeconds + " seconds. ");
lastModified = fileToScan.lastModified();
updateNextCheck(System.currentTimeMillis());
}
@@ -95,7 +98,7 @@ public class ReconfigureOnChangeFilter extends TurboFilter {
@Override
public FilterReply decide(Marker marker, Logger logger, Level level,
- String format, Object[] params, Throwable t) {
+ String format, Object[] params, Throwable t) {
if (!isStarted()) {
return FilterReply.NEUTRAL;
}
@@ -119,6 +122,7 @@ public class ReconfigureOnChangeFilter extends TurboFilter {
// by detaching reconfiguration to a new thread, we release the various
// locks held by the current thread, in particular, the AppenderAttachable
// reader lock.
+
private void detachReconfigurationToNewThread() {
// Even though this method resets the loggerContext, which clears the
// list of turbo filters including this instance, it is still possible
@@ -135,6 +139,7 @@ public class ReconfigureOnChangeFilter extends TurboFilter {
}
// This method is synchronized to prevent near-simultaneous re-configurations
+
protected boolean changeDetected() {
long now = System.currentTimeMillis();
if (now >= nextCheck) {
@@ -162,17 +167,32 @@ public class ReconfigureOnChangeFilter extends TurboFilter {
class ReconfiguringThread extends Thread {
public void run() {
- JoranConfigurator jc = new JoranConfigurator();
- jc.setContext(context);
LoggerContext lc = (LoggerContext) context;
- lc.reset();
- try {
- jc.doConfigure(fileToScan);
- } catch (JoranException e) {
- addError("Failure during reconfiguration", e);
+
+ if (fileToScan.toString().endsWith("groovy")) {
+ if (EnvUtil.isGroovyAvailable()) {
+ lc.reset();
+ GafferConfigurator gafferConfigurator = new GafferConfigurator(lc);
+ gafferConfigurator.run(fileToScan);
+ lc.getStatusManager().add(
+ new InfoStatus("done resetting the logging context", this));
+ } else {
+ StatusManager sm = context.getStatusManager();
+ sm.add(new ErrorStatus("Groovy classes are not available on the class path. ABORTING INITIALIZATION.",
+ context));
+ }
+ } else if (fileToScan.toString().endsWith("xml")) {
+ JoranConfigurator jc = new JoranConfigurator();
+ jc.setContext(context);
+ lc.reset();
+ try {
+ jc.doConfigure(fileToScan);
+ lc.getStatusManager().add(
+ new InfoStatus("done resetting the logging context", this));
+ } catch (JoranException e) {
+ addError("Failure during reconfiguration", e);
+ }
}
- lc.getStatusManager().add(
- new InfoStatus("done resetting the logging context", this));
}
}
}
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/util/EnvUtil.java b/logback-classic/src/main/java/ch/qos/logback/classic/util/EnvUtil.java
index ccd4ee3..73d92dc 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/util/EnvUtil.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/util/EnvUtil.java
@@ -19,7 +19,7 @@ package ch.qos.logback.classic.util;
public class EnvUtil {
- static boolean isGroovyAvailable() {
+ static public boolean isGroovyAvailable() {
ClassLoader classLoader = EnvUtil.class.getClassLoader();
try {
Class bindingClass = classLoader.loadClass("groovy.lang.Binding");
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java
index e9d6a07..8c18e06 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java
@@ -71,7 +71,6 @@ public class JaninoEventEvaluatorTest {
jee.start();
ILoggingEvent event = makeLoggingEvent(null);
- // System.out.println(event);
assertTrue(jee.evaluate(event));
}
@@ -81,7 +80,6 @@ public class JaninoEventEvaluatorTest {
jee.start();
ILoggingEvent event = makeLoggingEvent(null);
- // System.out.println(event);
assertTrue(jee.evaluate(event));
}
@@ -262,4 +260,13 @@ public class JaninoEventEvaluatorTest {
assertTrue(jee.evaluate(event));
}
+
+ @Test
+ public void nullMDC() throws EvaluationException {
+ jee.setExpression("mdc == null");
+ jee.start();
+
+ LoggingEvent event = makeLoggingEvent(null);
+ assertTrue(jee.evaluate(event));
+ }
}
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java
index 5611786..f39f1f3 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java
@@ -71,7 +71,7 @@ public class ConverterTest {
public void testLineOfCaller() {
{
DynamicConverter<ILoggingEvent> converter = new LineOfCallerConverter();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
// the number below should be the line number of the previous line
assertEquals("75", buf.toString());
@@ -82,14 +82,14 @@ public class ConverterTest {
public void testLevel() {
{
DynamicConverter<ILoggingEvent> converter = new LevelConverter();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
assertEquals("INFO", buf.toString());
}
{
DynamicConverter<ILoggingEvent> converter = new LevelConverter();
converter.setFormattingInfo(new FormatInfo(1, 1, true, false));
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
assertEquals("I", buf.toString());
}
@@ -98,7 +98,7 @@ public class ConverterTest {
@Test
public void testThread() {
DynamicConverter<ILoggingEvent> converter = new ThreadConverter();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
String regex = ClassicTestConstants.NAKED_MAIN_REGEX;
assertTrue(buf.toString().matches(regex));
@@ -107,7 +107,7 @@ public class ConverterTest {
@Test
public void testMessage() {
DynamicConverter<ILoggingEvent> converter = new MessageConverter();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
assertEquals("Some message", buf.toString());
}
@@ -115,7 +115,7 @@ public class ConverterTest {
@Test
public void testLineSeparator() {
DynamicConverter<ILoggingEvent> converter = new LineSeparatorConverter();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
assertEquals(CoreConstants.LINE_SEPARATOR, buf.toString());
}
@@ -124,7 +124,7 @@ public class ConverterTest {
public void testException() {
{
DynamicConverter<ILoggingEvent> converter = new ThrowableProxyConverter();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
}
@@ -132,7 +132,7 @@ public class ConverterTest {
DynamicConverter<ILoggingEvent> converter = new ThrowableProxyConverter();
this.optionList.add("3");
converter.setOptionList(this.optionList);
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
}
}
@@ -141,7 +141,7 @@ public class ConverterTest {
public void testLogger() {
{
ClassicConverter converter = new LoggerConverter();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
assertEquals(this.getClass().getName(), buf.toString());
}
@@ -151,7 +151,7 @@ public class ConverterTest {
this.optionList.add("20");
converter.setOptionList(this.optionList);
converter.start();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
assertEquals("c.q.l.c.p.ConverterTest", buf.toString());
}
@@ -162,7 +162,7 @@ public class ConverterTest {
this.optionList.add("0");
converter.setOptionList(this.optionList);
converter.start();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
assertEquals("ConverterTest", buf.toString());
}
@@ -174,7 +174,7 @@ public class ConverterTest {
this.optionList.add("5");
converter.setOptionList(this.optionList);
converter.start();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
char c = 'a';
int extraParts = 3;
@@ -203,7 +203,7 @@ public class ConverterTest {
@Test
public void testClass() {
DynamicConverter<ILoggingEvent> converter = new ClassOfCallerConverter();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
assertEquals(this.getClass().getName(), buf.toString());
}
@@ -211,7 +211,7 @@ public class ConverterTest {
@Test
public void testMethodOfCaller() {
DynamicConverter<ILoggingEvent> converter = new MethodOfCallerConverter();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
assertEquals("testMethodOfCaller", buf.toString());
}
@@ -219,7 +219,7 @@ public class ConverterTest {
@Test
public void testFileOfCaller() {
DynamicConverter<ILoggingEvent> converter = new FileOfCallerConverter();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
assertEquals("ConverterTest.java", buf.toString());
}
@@ -230,7 +230,7 @@ public class ConverterTest {
DynamicConverter<ILoggingEvent> converter = new CallerDataConverter();
converter.start();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
if (buf.length() < 10) {
fail("buf is too short");
@@ -244,7 +244,7 @@ public class ConverterTest {
converter.setOptionList(this.optionList);
converter.start();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
LoggingEvent event = makeLoggingEvent(null);
event.setMarker(MarkerFactory.getMarker("XXX"));
converter.write(buf, event);
@@ -262,7 +262,7 @@ public class ConverterTest {
converter.setOptionList(this.optionList);
converter.start();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
LoggingEvent event = makeLoggingEvent(null);
event.setMarker(MarkerFactory.getMarker("YYY"));
converter.write(buf, event);
@@ -279,7 +279,7 @@ public class ConverterTest {
converter.setOptionList(this.optionList);
converter.start();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
LoggingEvent event = makeLoggingEvent(null);
event.setMarker(MarkerFactory.getMarker("YYY"));
converter.write(buf, event);
@@ -297,7 +297,7 @@ public class ConverterTest {
converter.setOptionList(this.optionList);
converter.start();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
if (buf.length() < 10) {
fail("buf is too short");
@@ -310,8 +310,8 @@ public class ConverterTest {
@Test
public void testRelativeTime() throws Exception {
DynamicConverter<ILoggingEvent> converter = new RelativeTimeConverter();
- StringBuffer buf0 = new StringBuffer();
- StringBuffer buf1 = new StringBuffer();
+ StringBuilder buf0 = new StringBuilder();
+ StringBuilder buf1 = new StringBuilder();
ILoggingEvent e0 = makeLoggingEvent(null);
ILoggingEvent e1 = makeLoggingEvent(null);
converter.write(buf0, e0);
@@ -329,7 +329,7 @@ public class ConverterTest {
ILoggingEvent event = makeLoggingEvent(null);
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, event);
String expected = "<"
diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/CompositeConverter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/CompositeConverter.java
index 667d409..07e352e 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/pattern/CompositeConverter.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/CompositeConverter.java
@@ -15,12 +15,12 @@ package ch.qos.logback.core.pattern;
public class CompositeConverter<E> extends FormattingConverter<E> {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
Converter<E> childConverter;
public String convert(E event) {
if (buf.capacity() > MAX_CAPACITY) {
- buf = new StringBuffer(INITIAL_BUF_SIZE);
+ buf = new StringBuilder(INITIAL_BUF_SIZE);
} else {
buf.setLength(0);
}
@@ -36,7 +36,7 @@ public class CompositeConverter<E> extends FormattingConverter<E> {
}
public String toString() {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
buf.append("CompositeConverter<");
if(formattingInfo != null)
diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/Converter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/Converter.java
index 5a140d8..7a9c71e 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/pattern/Converter.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/Converter.java
@@ -38,7 +38,7 @@ abstract public class Converter<E> {
* @param buf The input buffer where data is appended
* @param event The event from where data is extracted
*/
- public void write(StringBuffer buf, E event) {
+ public void write(StringBuilder buf, E event) {
buf.append(convert(event));
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/FormattingConverter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/FormattingConverter.java
index b228d0d..09e2869 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/pattern/FormattingConverter.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/FormattingConverter.java
@@ -32,7 +32,8 @@ abstract public class FormattingConverter<E> extends Converter<E> {
this.formattingInfo = formattingInfo;
}
- final public void write(StringBuffer buf, E event) {
+ @Override
+ final public void write(StringBuilder buf, E event) {
String s = convert(event);
if(formattingInfo == null) {
diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutBase.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutBase.java
index 6a76153..d507887 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutBase.java
@@ -112,7 +112,7 @@ abstract public class PatternLayoutBase<E> extends LayoutBase<E> {
}
protected String writeLoopOnConverters(E event) {
- StringBuffer buf = new StringBuffer(128);
+ StringBuilder buf = new StringBuilder(128);
Converter<E> c = head;
while (c != null) {
c.write(buf, event);
diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/SpacePadder.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/SpacePadder.java
index b7b444e..76f9472 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/pattern/SpacePadder.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/SpacePadder.java
@@ -20,7 +20,7 @@ public class SpacePadder {
" ", // 16 spaces
" " }; // 32 spaces
- final static public void leftPad(StringBuffer buf, String s, int desiredLength) {
+ final static public void leftPad(StringBuilder buf, String s, int desiredLength) {
int actualLen = 0;
if (s != null) {
actualLen = s.length();
@@ -33,7 +33,7 @@ public class SpacePadder {
}
}
- final static public void rightPad(StringBuffer buf, String s, int desiredLength) {
+ final static public void rightPad(StringBuilder buf, String s, int desiredLength) {
int actualLen = 0;
if (s != null) {
actualLen = s.length();
@@ -49,7 +49,7 @@ public class SpacePadder {
/**
* Fast space padding method.
*/
- final static public void spacePad(StringBuffer sbuf, int length) {
+ final static public void spacePad(StringBuilder sbuf, int length) {
while (length >= 32) {
sbuf.append(SPACES[5]);
length -= 32;
diff --git a/logback-core/src/test/java/ch/qos/logback/core/pattern/SpacePadderTest.java b/logback-core/src/test/java/ch/qos/logback/core/pattern/SpacePadderTest.java
index 97866a6..de44af1 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/pattern/SpacePadderTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/pattern/SpacePadderTest.java
@@ -42,13 +42,13 @@ public class SpacePadderTest {
@Test
public void smoke() {
{
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
String s = "a";
SpacePadder.leftPad(buf, s, 4);
assertEquals(" a", buf.toString());
}
{
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
String s = "a";
SpacePadder.rightPad(buf, s, 4);
assertEquals("a ", buf.toString());
@@ -59,12 +59,12 @@ public class SpacePadderTest {
public void nullString() {
String s = null;
{
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
SpacePadder.leftPad(buf, s, 2);
assertEquals(" ", buf.toString());
}
{
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
SpacePadder.rightPad(buf, s, 2);
assertEquals(" ", buf.toString());
}
@@ -73,14 +73,14 @@ public class SpacePadderTest {
@Test
public void longString() {
{
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
String s = "abc";
SpacePadder.leftPad(buf, s, 2);
assertEquals(s, buf.toString());
}
{
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
String s = "abc";
SpacePadder.rightPad(buf, s, 2);
assertEquals(s, buf.toString());
@@ -90,13 +90,13 @@ public class SpacePadderTest {
@Test
public void lengthyPad() {
{
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
String s = "abc";
SpacePadder.leftPad(buf, s, 33);
assertEquals(" abc", buf.toString());
}
{
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
String s = "abc";
SpacePadder.rightPad(buf, s, 33);
assertEquals("abc ", buf.toString());
diff --git a/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/CompilerTest.java b/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/CompilerTest.java
index 76848bc..8c64c59 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/CompilerTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/CompilerTest.java
@@ -43,7 +43,7 @@ public class CompilerTest {
String write(final Converter<Object> head, Object event) {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
Converter<Object> c = head;
while (c != null) {
c.write(buf, event);
diff --git a/logback-site/src/site/pages/manual/filters.html b/logback-site/src/site/pages/manual/filters.html
index 5e49139..6340456 100644
--- a/logback-site/src/site/pages/manual/filters.html
+++ b/logback-site/src/site/pages/manual/filters.html
@@ -297,7 +297,9 @@ public class SampleFilter extends Filter>ILoggingEvent> {
TRACE, DEBUG, INFO, WARN and ERROR are also exported into the
scope of the expression. Thus, "event.level == DEBUG" is a valid
groovy expression which will return <code>true</code> only if the
- current logging event's level is equal to DEBUG.
+ current logging event's level is identical to DEBUG. For other
+ comparison operators, the level field should be converter to
+ integer with the <code>toInt()</code> operator.
</p>
<p>Here is a more complete example.</p>
@@ -309,7 +311,7 @@ public class SampleFilter extends Filter>ILoggingEvent> {
<b><filter class="ch.qos.logback.core.filter.EvaluatorFilter">
<evaluator class="ch.qos.logback.classic.boolex.GEventEvaluator">
<expression>
- e.level>=WARN
+ e.level.toInt() >= WARN.toInt()
&amp;&amp; <!-- Stands for && in XML -->
!(e.mdc?.get("req.userAgent") ~= /Googlebot|msnbot|Yahoo/ )
</expression>
@@ -471,7 +473,9 @@ public class SampleFilter extends Filter>ILoggingEvent> {
<td><code>Map</code></td>
<td>A map containing all the MDC values at the time of the
creation of the logging event. A value can be accessed by
- using the following expression: <em>mdc.get("myKey")</em>.
+ using the following expression: <em>mdc.get("myKey")</em>. The
+ 'mdc' variable can be null and this possibility should be
+ checked for in evaluator expressions.
<p>The <code>java.util.Map</code> type is non-parametirezied
because Janino does not support generics. It follows that the
-----------------------------------------------------------------------
Summary of changes:
.../ch/qos/logback/access/html/HTMLLayout.java | 2 +-
.../classic/gaffer/GafferConfigurator.groovy | 5 ++
.../ch/qos/logback/classic/html/HTMLLayout.java | 2 +-
.../classic/turbo/ReconfigureOnChangeFilter.java | 48 ++++++++++++++------
.../java/ch/qos/logback/classic/util/EnvUtil.java | 2 +-
.../classic/boolex/JaninoEventEvaluatorTest.java | 11 ++++-
.../qos/logback/classic/pattern/ConverterTest.java | 46 +++++++++---------
.../logback/core/pattern/CompositeConverter.java | 6 +-
.../ch/qos/logback/core/pattern/Converter.java | 2 +-
.../logback/core/pattern/FormattingConverter.java | 3 +-
.../logback/core/pattern/PatternLayoutBase.java | 2 +-
.../ch/qos/logback/core/pattern/SpacePadder.java | 6 +-
.../qos/logback/core/pattern/SpacePadderTest.java | 16 +++---
.../logback/core/pattern/parser/CompilerTest.java | 2 +-
logback-site/src/site/pages/manual/filters.html | 10 +++-
15 files changed, 100 insertions(+), 63 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
More information about the logback-dev
mailing list