Author: jbonofre
Date: Fri Oct 22 08:25:01 2010
New Revision: 1026241
URL: http://svn.apache.org/viewvc?rev=1026241&view=rev
Log:
[KARAF-233] Add a log:clear command.
Added:
karaf/trunk/assembly/src/main/distribution/unix-shell/data/
karaf/trunk/assembly/src/main/distribution/unix-shell/data/karaf.out
karaf/trunk/shell/log/src/main/java/org/apache/karaf/shell/log/ClearLog.java
Modified:
karaf/trunk/shell/log/src/main/java/org/apache/karaf/shell/log/LruList.java
karaf/trunk/shell/log/src/main/resources/OSGI-INF/blueprint/shell-log.xml
Added: karaf/trunk/assembly/src/main/distribution/unix-shell/data/karaf.out
URL:
http://svn.apache.org/viewvc/karaf/trunk/assembly/src/main/distribution/unix-shell/data/karaf.out?rev=1026241&view=auto
==============================================================================
--- karaf/trunk/assembly/src/main/distribution/unix-shell/data/karaf.out (added)
+++ karaf/trunk/assembly/src/main/distribution/unix-shell/data/karaf.out Fri
Oct 22 08:25:01 2010
@@ -0,0 +1,9 @@
+Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/karaf/main/Main
+Caused by: java.lang.ClassNotFoundException: org.apache.karaf.main.Main
+ at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
+ at java.security.AccessController.doPrivileged(Native Method)
+ at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
+ at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
+ at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
+ at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
+Could not find the main class: org.apache.karaf.main.Main. Program will exit.
Added:
karaf/trunk/shell/log/src/main/java/org/apache/karaf/shell/log/ClearLog.java
URL:
http://svn.apache.org/viewvc/karaf/trunk/shell/log/src/main/java/org/apache/karaf/shell/log/ClearLog.java?rev=1026241&view=auto
==============================================================================
---
karaf/trunk/shell/log/src/main/java/org/apache/karaf/shell/log/ClearLog.java
(added)
+++
karaf/trunk/shell/log/src/main/java/org/apache/karaf/shell/log/ClearLog.java
Fri Oct 22 08:25:01 2010
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.shell.log;
+
+import org.apache.felix.gogo.commands.Command;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+
+/**
+ * Clear the last log entries.
+ */
+...@command(scope = "log", name = "clear", description = "Clear log entries.")
+public class ClearLog extends OsgiCommandSupport {
+
+ protected LruList events;
+
+ public LruList getEvents() {
+ return events;
+ }
+
+ public void setEvents(LruList events) {
+ this.events = events;
+ }
+
+ protected Object doExecute() throws Exception {
+ events.clear();
+ return null;
+ }
+
+}
Modified:
karaf/trunk/shell/log/src/main/java/org/apache/karaf/shell/log/LruList.java
URL:
http://svn.apache.org/viewvc/karaf/trunk/shell/log/src/main/java/org/apache/karaf/shell/log/LruList.java?rev=1026241&r1=1026240&r2=1026241&view=diff
==============================================================================
--- karaf/trunk/shell/log/src/main/java/org/apache/karaf/shell/log/LruList.java
(original)
+++ karaf/trunk/shell/log/src/main/java/org/apache/karaf/shell/log/LruList.java
Fri Oct 22 08:25:01 2010
@@ -55,6 +55,14 @@ public class LruList {
}
}
+ public void clear() {
+ synchronized (elements) {
+ start = 0;
+ end = 0;
+ elements = new PaxLoggingEvent[maxElements];
+ }
+ }
+
public void add(PaxLoggingEvent element) {
synchronized (elements) {
if (null == element) {
Modified:
karaf/trunk/shell/log/src/main/resources/OSGI-INF/blueprint/shell-log.xml
URL:
http://svn.apache.org/viewvc/karaf/trunk/shell/log/src/main/resources/OSGI-INF/blueprint/shell-log.xml?rev=1026241&r1=1026240&r2=1026241&view=diff
==============================================================================
--- karaf/trunk/shell/log/src/main/resources/OSGI-INF/blueprint/shell-log.xml
(original)
+++ karaf/trunk/shell/log/src/main/resources/OSGI-INF/blueprint/shell-log.xml
Fri Oct 22 08:25:01 2010
@@ -53,6 +53,11 @@
<property name="events" ref="events"/>
</action>
</command>
+ <command name="log/clear">
+ <action class="org.apache.karaf.shell.log.ClearLog">
+ <property name="events" ref="events"/>
+ </action>
+ </command>
<command name="log/get">
<action class="org.apache.karaf.shell.log.GetLogLevel" />
</command>