提交 98ccd9d6 编写于 作者: J Jesse Glick

Merge branch 'JENKINS-22839' of github.com:daniel-beck/jenkins

......@@ -297,6 +297,12 @@ public class LogRecorder extends AbstractModelObject implements Saveable {
rsp.sendRedirect2(redirect);
}
@RequirePOST
public void doClear(StaplerRequest req, StaplerResponse rsp) throws IOException {
handler.clear();
rsp.sendRedirect2(".");
}
/**
* Loads the settings from a file.
*/
......
......@@ -59,6 +59,11 @@ public class RingBufferLogHandler extends Handler {
}
}
public synchronized void clear() {
size = 0;
start = 0;
}
/**
* Returns the list view of {@link LogRecord}s in the ring buffer.
*
......
......@@ -37,6 +37,10 @@ THE SOFTWARE.
<t:logRecords logRecords="${entry.value}"/>
</j:forEach>
<form method="post" id='clear-logrecorder' action="clear">
<f:submit value="${%Clear This Log}" />
</form>
<st:include it="${it.parent}" page="feeds.jelly" />
</l:main-panel>
</l:layout>
......
......@@ -54,6 +54,21 @@ public class LogRecorderTest {
assertFalse(matches("", "hudson.model.Hudson", Level.FINE));
}
@Test public void testClearing() {
LogRecorder lr = new LogRecorder("foo");
LogRecorder.Target t = new LogRecorder.Target("", Level.FINE);
lr.targets.add(t);
LogRecord record = createLogRecord("jenkins", Level.INFO, "message");
lr.handler.publish(record);
assertEquals(lr.handler.getView().get(0), record);
assertTrue(lr.handler.getView().size() == 1);
lr.handler.clear();
assertTrue(lr.handler.getView().size() == 0);
}
@Test public void testSpecificExclusion() {
LogRecorder lr = new LogRecorder("foo");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册