You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2008/10/10 19:29:57 UTC
svn commit: r703527 - in
/geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main:
java/org/apache/geronimo/gshell/commands/log4j/ resources/META-INF/spring/
resources/org/apache/geronimo/gshell/commands/log4j/
Author: jdillon
Date: Fri Oct 10 10:29:57 2008
New Revision: 703527
URL: http://svn.apache.org/viewvc?rev=703527&view=rev
Log:
Add new commands
Added:
geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/java/org/apache/geronimo/gshell/commands/log4j/LoggersAction.java (with props)
geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/java/org/apache/geronimo/gshell/commands/log4j/MdcAction.java (with props)
geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/java/org/apache/geronimo/gshell/commands/log4j/NdcAction.java (with props)
geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/LoggersAction.properties (contents, props changed)
- copied, changed from r703515, geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/LoggerAction.properties
geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/MdcAction.properties (with props)
geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/NdcAction.properties (with props)
Modified:
geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/META-INF/spring/components.xml
Added: geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/java/org/apache/geronimo/gshell/commands/log4j/LoggersAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/java/org/apache/geronimo/gshell/commands/log4j/LoggersAction.java?rev=703527&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/java/org/apache/geronimo/gshell/commands/log4j/LoggersAction.java (added)
+++ geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/java/org/apache/geronimo/gshell/commands/log4j/LoggersAction.java Fri Oct 10 10:29:57 2008
@@ -0,0 +1,51 @@
+/*
+ * 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.geronimo.gshell.commands.log4j;
+
+import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.command.CommandContext;
+import org.apache.geronimo.gshell.io.IO;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+
+import java.util.Enumeration;
+
+/**
+ * Display all loggers.
+ *
+ * @version $Rev$ $Date$
+ */
+public class LoggersAction
+ implements CommandAction
+{
+ public Object execute(final CommandContext context) throws Exception {
+ assert context != null;
+ IO io = context.getIo();
+
+ Enumeration n = LogManager.getCurrentLoggers();
+
+ while (n.hasMoreElements()) {
+ Logger logger = (Logger)n.nextElement();
+ io.info("{}={}", logger.getName(), logger.getLevel());
+ }
+
+ return Result.SUCCESS;
+ }
+}
\ No newline at end of file
Propchange: geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/java/org/apache/geronimo/gshell/commands/log4j/LoggersAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/java/org/apache/geronimo/gshell/commands/log4j/LoggersAction.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/java/org/apache/geronimo/gshell/commands/log4j/LoggersAction.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/java/org/apache/geronimo/gshell/commands/log4j/MdcAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/java/org/apache/geronimo/gshell/commands/log4j/MdcAction.java?rev=703527&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/java/org/apache/geronimo/gshell/commands/log4j/MdcAction.java (added)
+++ geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/java/org/apache/geronimo/gshell/commands/log4j/MdcAction.java Fri Oct 10 10:29:57 2008
@@ -0,0 +1,72 @@
+/*
+ * 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.geronimo.gshell.commands.log4j;
+
+import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.command.CommandContext;
+import org.apache.geronimo.gshell.io.IO;
+import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.geronimo.gshell.clp.Option;
+import org.apache.log4j.MDC;
+
+import java.util.Map;
+
+/**
+ * Manage the {@link MDC} for the current thread.
+ *
+ * @version $Rev$ $Date$
+ */
+public class MdcAction
+ implements CommandAction
+{
+ @Option(name="-r", aliases={"--remove"})
+ private boolean remove;
+
+ @Argument(index=0)
+ private String name;
+
+ @Argument(index=1)
+ private Object value;
+
+ public Object execute(final CommandContext context) throws Exception {
+ assert context != null;
+ IO io = context.getIo();
+
+ if (remove) {
+ MDC.remove(name);
+ }
+ else if (name != null && value != null) {
+ MDC.put(name, value);
+ }
+ else if (name != null) {
+ io.info("{}", MDC.get(name));
+ }
+ else {
+ Map map = MDC.getContext();
+ if (map != null) {
+ for (Object key : map.keySet()) {
+ io.info("{}={}", key, map.get(key));
+ }
+ }
+ }
+
+ return Result.SUCCESS;
+ }
+}
\ No newline at end of file
Propchange: geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/java/org/apache/geronimo/gshell/commands/log4j/MdcAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/java/org/apache/geronimo/gshell/commands/log4j/MdcAction.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/java/org/apache/geronimo/gshell/commands/log4j/MdcAction.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/java/org/apache/geronimo/gshell/commands/log4j/NdcAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/java/org/apache/geronimo/gshell/commands/log4j/NdcAction.java?rev=703527&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/java/org/apache/geronimo/gshell/commands/log4j/NdcAction.java (added)
+++ geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/java/org/apache/geronimo/gshell/commands/log4j/NdcAction.java Fri Oct 10 10:29:57 2008
@@ -0,0 +1,72 @@
+/*
+ * 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.geronimo.gshell.commands.log4j;
+
+import org.apache.geronimo.gshell.command.CommandAction;
+import org.apache.geronimo.gshell.command.CommandContext;
+import org.apache.geronimo.gshell.io.IO;
+import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.log4j.NDC;
+
+/**
+ * Manage the {@link NDC} for the current thread.
+ *
+ * @version $Rev$ $Date$
+ */
+public class NdcAction
+ implements CommandAction
+{
+ private enum Type
+ {
+ PUSH,
+ POP,
+ PEEK
+ }
+
+ @Argument(index=0, required=true)
+ private Type operation;
+
+ @Argument(index=1)
+ private String arg;
+
+ public Object execute(final CommandContext context) throws Exception {
+ assert context != null;
+ IO io = context.getIo();
+
+ switch (operation) {
+ case PUSH:
+ if (arg == null) {
+ throw new RuntimeException("Missing required argument");
+ }
+ NDC.push(arg);
+ break;
+
+ case POP:
+ io.info("{}", NDC.pop());
+ break;
+
+ case PEEK:
+ io.info("{}", NDC.peek());
+ break;
+ }
+
+ return Result.SUCCESS;
+ }
+}
\ No newline at end of file
Propchange: geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/java/org/apache/geronimo/gshell/commands/log4j/NdcAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/java/org/apache/geronimo/gshell/commands/log4j/NdcAction.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/java/org/apache/geronimo/gshell/commands/log4j/NdcAction.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/META-INF/spring/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/META-INF/spring/components.xml?rev=703527&r1=703526&r2=703527&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/META-INF/spring/components.xml (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/META-INF/spring/components.xml Fri Oct 10 10:29:57 2008
@@ -32,6 +32,18 @@
<gshell:command name="log4j/logger">
<gshell:action class="org.apache.geronimo.gshell.commands.log4j.LoggerAction"/>
</gshell:command>
+
+ <gshell:command name="log4j/loggers" type="stateless">
+ <gshell:action class="org.apache.geronimo.gshell.commands.log4j.LoggersAction"/>
+ </gshell:command>
+
+ <gshell:command name="log4j/mdc">
+ <gshell:action class="org.apache.geronimo.gshell.commands.log4j.MdcAction"/>
+ </gshell:command>
+
+ <gshell:command name="log4j/ndc">
+ <gshell:action class="org.apache.geronimo.gshell.commands.log4j.NdcAction"/>
+ </gshell:command>
</gshell:command-bundle>
</gshell:plugin>
Copied: geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/LoggersAction.properties (from r703515, geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/LoggerAction.properties)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/LoggersAction.properties?p2=geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/LoggersAction.properties&p1=geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/LoggerAction.properties&r1=703515&r2=703527&rev=703527&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/LoggerAction.properties (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/LoggersAction.properties Fri Oct 10 10:29:57 2008
@@ -21,13 +21,7 @@
## $Rev$ $Date$
##
-command.description=Get or set a loggers level.
-
-command.argument.loggerName=Logger name to query/modify
-command.argument.loggerName.token=LOGGER
-
-command.argument.levelName=Level to set logger at
-command.argument.levelName.token=LEVEL
+command.description=List all configured loggers.
command.manual=\
- TODO: logger manual
\ No newline at end of file
+ TODO: loggers manual
\ No newline at end of file
Propchange: geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/LoggersAction.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/LoggersAction.properties
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/LoggersAction.properties
------------------------------------------------------------------------------
svn:mergeinfo =
Propchange: geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/LoggersAction.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/MdcAction.properties
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/MdcAction.properties?rev=703527&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/MdcAction.properties (added)
+++ geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/MdcAction.properties Fri Oct 10 10:29:57 2008
@@ -0,0 +1,35 @@
+##
+## 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.
+##
+
+##
+## $Rev$ $Date$
+##
+
+command.description=Manage the MDC for the current thread.
+
+command.option.remove=Remove the context for NAME
+
+command.argument.name=Context name
+command.argument.name.token=NAME
+
+command.argument.value=Context value
+command.argument.value.token=VALUE
+
+command.manual=\
+ TODO: mdc manual
\ No newline at end of file
Propchange: geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/MdcAction.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/MdcAction.properties
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/MdcAction.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/NdcAction.properties
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/NdcAction.properties?rev=703527&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/NdcAction.properties (added)
+++ geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/NdcAction.properties Fri Oct 10 10:29:57 2008
@@ -0,0 +1,33 @@
+##
+## 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.
+##
+
+##
+## $Rev$ $Date$
+##
+
+command.description=Manage the NDC for the current thread.
+
+command.argument.operation=Stack operation: PUSH, POP, PEEK
+command.argument.name.token=OPERATION
+
+command.argument.arg=Pop argument value
+command.argument.arg.token=VALUE
+
+command.manual=\
+ TODO: ndc manual
\ No newline at end of file
Propchange: geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/NdcAction.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/NdcAction.properties
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/gshell/trunk/gshell-commands/gshell-log4j/src/main/resources/org/apache/geronimo/gshell/commands/log4j/NdcAction.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain