You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2012/01/21 23:34:38 UTC
svn commit: r1234434 - in
/activemq/activemq-apollo/trunk/apollo-cli/src/main:
resources/META-INF/services/org.apache.activemq.apollo/apollo-main.index
scala/org/apache/activemq/apollo/cli/Apollo.scala
Author: chirino
Date: Sat Jan 21 22:34:37 2012
New Revision: 1234434
URL: http://svn.apache.org/viewvc?rev=1234434&view=rev
Log:
You can now use --log=DEBUG before an apollo cli sub command to enable debug logging to the console. Also use System.exit to make sure we exit even if there are non-daemon threads that got started.
Added:
activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/META-INF/services/org.apache.activemq.apollo/apollo-main.index
Modified:
activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/Apollo.scala
Added: activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/META-INF/services/org.apache.activemq.apollo/apollo-main.index
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/META-INF/services/org.apache.activemq.apollo/apollo-main.index?rev=1234434&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/META-INF/services/org.apache.activemq.apollo/apollo-main.index (added)
+++ activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/META-INF/services/org.apache.activemq.apollo/apollo-main.index Sat Jan 21 22:34:37 2012
@@ -0,0 +1,17 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+org.apache.activemq.apollo.cli.Apollo
Modified: activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/Apollo.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/Apollo.scala?rev=1234434&r1=1234433&r2=1234434&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/Apollo.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/Apollo.scala Sat Jan 21 22:34:37 2012
@@ -16,7 +16,6 @@
*/
package org.apache.activemq.apollo.cli
-import org.apache.felix.gogo.commands.{Action, Option => option, Argument => argument, Command => command}
import org.apache.karaf.shell.console.Main
import org.apache.karaf.shell.console.jline.Console
import jline.Terminal
@@ -24,11 +23,11 @@ import org.fusesource.jansi.Ansi
import org.apache.activemq.apollo.util.FileSupport._
import org.apache.felix.service.command.CommandSession
import org.apache.felix.gogo.runtime.CommandProcessorImpl
-import org.apache.activemq.apollo.util.FileSupport.RichFile._
import java.util.logging.LogManager
import java.io.{FileInputStream, File, PrintStream, InputStream}
import org.apache.log4j.PropertyConfigurator
import java.util.Properties
+import org.apache.felix.gogo.commands.{Action, Option => option, Argument => argument, Command => command}
/**
* <p>
@@ -36,7 +35,7 @@ import java.util.Properties
*
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/
-object Apollo {
+object Apollo extends Apollo {
def main(args: Array[String]) = {
if( System.getProperty("java.util.logging.config.file") == null ) {
@@ -58,12 +57,9 @@ object Apollo {
}
}
- // Just in case your running a sub command an not
- // the broker
- PropertyConfigurator.configure(new Properties())
-
Ansi.ansi()
- new Apollo().run(args)
+ Apollo.run(("apollo"::args.toList).toArray)
+ System.exit(0)
}
// Some ANSI helpers...
@@ -82,6 +78,8 @@ object Apollo {
}
}
+ override def getDiscoveryResource = "META-INF/services/org.apache.activemq.apollo/apollo-main.index"
+
def print_tips(out: PrintStream) = using(getClass().getResourceAsStream("tips.txt")) { source=>
copy(source, out)
}
@@ -131,10 +129,41 @@ class Apollo extends Main with Action {
}
}
+ @option(name = "--log", description="The logging level use.")
+ var log_level:String = "NONE"
+
@argument(name = "args", description = "apollo sub command arguments", multiValued=true)
- var args = Array[String]()
+ var args:Array[String] = _
def execute(session: CommandSession): AnyRef = {
+
+ // Just in case your running a sub command an not
+ // the broker
+ var log_properties: Properties = new Properties()
+ log_properties.put("log4j.appender.console", "org.apache.log4j.ConsoleAppender")
+ log_properties.put("log4j.appender.console.layout", "org.apache.log4j.PatternLayout")
+ log_properties.put("log4j.appender.console.layout.ConversionPattern", "%-5p | %m%n")
+
+
+ log_level = log_level.toUpperCase()
+ log_level match {
+ case "NONE" => log_properties.clear()
+ log_properties.put("log4j.rootLogger", "FATAL")
+ case "FATAL" =>
+ log_properties.put("log4j.rootLogger", log_level+", console")
+ case "ERROR" =>
+ log_properties.put("log4j.rootLogger", log_level+", console")
+ case "WARN" =>
+ log_properties.put("log4j.rootLogger", log_level+", console")
+ case "INFO" =>
+ log_properties.put("log4j.rootLogger", log_level+", console")
+ case "DEBUG" =>
+ log_properties.put("log4j.rootLogger", log_level+", console")
+ case "TRACE" =>
+ log_properties.put("log4j.rootLogger", log_level+", console")
+ }
+ PropertyConfigurator.configure(log_properties)
+
run(session, args)
null
}