You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2014/10/10 22:50:31 UTC
svn commit: r1630985 - in /sling/trunk/tooling/ide/eclipse-core:
META-INF/MANIFEST.MF OSGI-INF/TraceCommandExecutionEventsHandler.xml
build.properties
src/org/apache/sling/ide/eclipse/core/debug/impl/TraceCommandExecutionEventsHandler.java
Author: rombert
Date: Fri Oct 10 20:50:30 2014
New Revision: 1630985
URL: http://svn.apache.org/r1630985
Log:
SLING-4028 - Allow printing tracing output to the console
Added:
sling/trunk/tooling/ide/eclipse-core/OSGI-INF/TraceCommandExecutionEventsHandler.xml
sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/debug/impl/TraceCommandExecutionEventsHandler.java
Modified:
sling/trunk/tooling/ide/eclipse-core/META-INF/MANIFEST.MF
sling/trunk/tooling/ide/eclipse-core/build.properties
Modified: sling/trunk/tooling/ide/eclipse-core/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-core/META-INF/MANIFEST.MF?rev=1630985&r1=1630984&r2=1630985&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-core/META-INF/MANIFEST.MF (original)
+++ sling/trunk/tooling/ide/eclipse-core/META-INF/MANIFEST.MF Fri Oct 10 20:50:30 2014
@@ -47,3 +47,4 @@ Export-Package: org.apache.sling.ide.ecl
.eclipse.core.debug,org.apache.sling.ide.eclipse.core.internal,org.ap
ache.sling.ide.eclipse.core.progress,org.apache.sling.ide.eclipse.int
ernal.validation;x-friends:="org.apache.sling.ide.eclipse-test"
+Service-Component: OSGI-INF/TraceCommandExecutionEventsHandler.xml
Added: sling/trunk/tooling/ide/eclipse-core/OSGI-INF/TraceCommandExecutionEventsHandler.xml
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-core/OSGI-INF/TraceCommandExecutionEventsHandler.xml?rev=1630985&view=auto
==============================================================================
--- sling/trunk/tooling/ide/eclipse-core/OSGI-INF/TraceCommandExecutionEventsHandler.xml (added)
+++ sling/trunk/tooling/ide/eclipse-core/OSGI-INF/TraceCommandExecutionEventsHandler.xml Fri Oct 10 20:50:30 2014
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0">
+ <implementation class="org.apache.sling.ide.eclipse.core.debug.impl.TraceCommandExecutionEventsHandler" />
+ <reference bind="bindLogger" cardinality="1..1" interface="org.apache.sling.ide.log.Logger" name="Logger" policy="static" target="(listener.symbolic.name=org.apache.sling.ide.eclipse-core)" unbind="unbindLogger"/>
+ <service>
+ <provide interface="org.osgi.service.event.EventHandler" />
+ </service>
+ <property name="event.topics" value="org/apache/sling/ide/transport" />
+</scr:component>
Modified: sling/trunk/tooling/ide/eclipse-core/build.properties
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-core/build.properties?rev=1630985&r1=1630984&r2=1630985&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-core/build.properties (original)
+++ sling/trunk/tooling/ide/eclipse-core/build.properties Fri Oct 10 20:50:30 2014
@@ -2,7 +2,8 @@ output.. = bin/
bin.includes = META-INF/,\
.,\
.options,\
- plugin.xml
+ plugin.xml,\
+ OSGI-INF/
jars.compile.order = .,\
commons-httpclient.jar
source.. = src/
Added: sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/debug/impl/TraceCommandExecutionEventsHandler.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/debug/impl/TraceCommandExecutionEventsHandler.java?rev=1630985&view=auto
==============================================================================
--- sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/debug/impl/TraceCommandExecutionEventsHandler.java (added)
+++ sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/debug/impl/TraceCommandExecutionEventsHandler.java Fri Oct 10 20:50:30 2014
@@ -0,0 +1,65 @@
+/*
+ * 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.sling.ide.eclipse.core.debug.impl;
+
+import java.text.DateFormat;
+import java.util.Date;
+
+import org.apache.sling.ide.log.Logger;
+import org.apache.sling.ide.transport.CommandExecutionProperties;
+import org.osgi.service.event.Event;
+import org.osgi.service.event.EventHandler;
+
+/**
+ * The <tt>TraceCommandExecutionEventsHandler</tt> listens to events related to command execution and writes them using
+ * the PluginLogger
+ *
+ */
+public class TraceCommandExecutionEventsHandler implements EventHandler {
+
+ private Logger logger;
+
+ @Override
+ public void handleEvent(Event event) {
+
+ Long start = (Long) event.getProperty(CommandExecutionProperties.TIMESTAMP_START);
+ Long end = (Long) event.getProperty(CommandExecutionProperties.TIMESTAMP_END);
+ String type = (String) event.getProperty(CommandExecutionProperties.ACTION_TYPE);
+ String target = (String) event.getProperty(CommandExecutionProperties.ACTION_TARGET);
+ String result = (String) event.getProperty(CommandExecutionProperties.RESULT_TEXT);
+ Throwable t = (Throwable) event.getProperty(CommandExecutionProperties.RESULT_THROWABLE);
+
+ // TODO format copied from SlingConsoleEventListener
+ StringBuilder message = new StringBuilder();
+ DateFormat format = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG);
+ message.append("[").append(format.format(new Date(start))).append("] ").append(type).append(" -> ")
+ .append(target);
+ message.append(" : ").append(result).append(" (").append(end - start).append(" ms)");
+
+ logger.trace(message.toString(), t);
+ }
+
+ protected void bindLogger(Logger logger) {
+ this.logger = logger;
+ }
+
+ protected void unbindLogger(Logger logger) {
+ if (this.logger == logger)
+ this.logger = null;
+ }
+
+}