]> git.argeo.org Git - gpl/argeo-slc.git/commitdiff
Restructure example
authorMathieu Baudier <mbaudier@argeo.org>
Sat, 21 Jun 2008 11:59:18 +0000 (11:59 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Sat, 21 Jun 2008 11:59:18 +0000 (11:59 +0000)
Improve logging

git-svn-id: https://svn.argeo.org/slc/trunk@1259 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/CompositeTreeTestDefinition.java
org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java
org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResultLogger.java
org.argeo.slc.core/src/main/java/org/argeo/slc/spring/SpringUtils.java
org.argeo.slc.core/src/main/resources/org/argeo/slc/castor/spring/applicationContext.xml
org.argeo.slc.core/src/main/resources/org/argeo/slc/core/process/spring/applicationContext.xml [new file with mode: 0644]
org.argeo.slc.core/src/test/resources/log4j.properties

index 91534e36d75511c03129869e2a39a2bb4c469ccb..3468bcb255c434f56bbbcfd40127ee1e64aee814 100644 (file)
@@ -29,7 +29,8 @@ public class CompositeTreeTestDefinition implements TestDefinition,
        private StructureRegistry<TreeSPath> registry;\r
 \r
        public void execute(TestRun testRun) {\r
-               log.info("Execute sequence of test definitions...");\r
+               if (log.isTraceEnabled())\r
+                       log.trace("Execute sequence of test definitions...");\r
 \r
                int i = 0;\r
                for (TestDefinition task : tasks) {\r
index 7e7ae68b7a65cefe539ab9c9339436744ad5ea1e..f34561a9e3b33881d2bd9c425f2d7990b2795132 100644 (file)
@@ -34,7 +34,7 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
 \r
        private TreeSPath currentPath;\r
        private TestRun currentTestRun;\r
-       \r
+\r
        private Map<String, String> rootTags = new TreeMap<String, String>();\r
 \r
        private Date closeDate;\r
@@ -80,13 +80,15 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
                                if (!elements.containsKey(p)) {\r
                                        StructureElement elem = registry.getElement(p);\r
                                        if (elem != null) {\r
-                                               \r
-                                               if(elements.size()==0 && (elem instanceof SimpleSElement)){\r
-                                                       SimpleSElement sElem = ((SimpleSElement)elem).clone();\r
+\r
+                                               if (elements.size() == 0\r
+                                                               && (elem instanceof SimpleSElement)) {\r
+                                                       SimpleSElement sElem = ((SimpleSElement) elem)\r
+                                                                       .clone();\r
                                                        sElem.getTags().putAll(rootTags);\r
                                                        elem = sElem;\r
                                                }\r
-                                               \r
+\r
                                                elements.put(p, elem);\r
                                        }\r
                                } else {\r
@@ -131,7 +133,8 @@ public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,
                }\r
                isClosed = true;\r
 \r
-               log.info("Test Result #" + getUuid() + " closed.");\r
+               if (log.isTraceEnabled())\r
+                       log.trace("Test Result " + getUuid() + " closed.");\r
        }\r
 \r
        public Date getCloseDate() {\r
index 2246e18b0ef23d4b450c129df73f62fb27df6195..78808cbbf64efe4d0b5fb394da3dc3f5e5ecce4d 100644 (file)
@@ -16,6 +16,8 @@ import org.argeo.slc.core.test.TestStatus;
 public class TreeTestResultLogger implements TestResultListener<TreeTestResult> {\r
 \r
        private static Log log = LogFactory.getLog(TreeTestResultLogger.class);\r
+       \r
+       private Boolean logExceptionMessages = false;\r
 \r
        public void resultPartAdded(TreeTestResult testResult,\r
                        TestResultPart testResultPart) {\r
@@ -26,7 +28,10 @@ public class TreeTestResultLogger implements TestResultListener<TreeTestResult>
                } else if (testResultPart.getStatus().equals(TestStatus.FAILED)) {\r
                        log.warn(msg);\r
                } else if (testResultPart.getStatus().equals(TestStatus.ERROR)) {\r
-                       log.error(msg + "\n" + testResultPart.getExceptionMessage());\r
+                       if(logExceptionMessages || log.isDebugEnabled())\r
+                               msg = msg + "\n" + testResultPart.getExceptionMessage();\r
+                       \r
+                       log.error(msg);\r
                } else {\r
                        log.error("Unknow test status: " + msg);\r
                }\r
@@ -36,4 +41,9 @@ public class TreeTestResultLogger implements TestResultListener<TreeTestResult>
                log.info("Test result " + testResult.getUuid() + " closed.");\r
        }\r
 \r
+       public void setLogExceptionMessages(Boolean logExceptionMessages) {\r
+               this.logExceptionMessages = logExceptionMessages;\r
+       }\r
+\r
+       \r
 }\r
index 73f1ffde37647b9465267ef4cec4316e6dcd17c5..8ef13560cf2695a84139c91ad9d77dafe67b2d8b 100644 (file)
@@ -27,7 +27,7 @@ public class SpringUtils {
                try {\r
                        if (res.getURL().getPath().equals("/"))\r
                                return null;\r
-\r
+                       \r
                        String urlStr = res.getURL().toString();\r
                        if (urlStr.charAt(urlStr.length() - 1) == '/')\r
                                urlStr = urlStr.substring(0, urlStr.length() - 2);\r
@@ -42,14 +42,8 @@ public class SpringUtils {
 \r
        public static String extractRelativePath(Resource ancestor, Resource child) {\r
                try {\r
-                       String childPath = child.getURL().getPath();\r
-                       String ancestorPath = ancestor.getURL().getPath();\r
-\r
-                       if (log.isTraceEnabled())\r
-                               log.trace("extractRelativePath(): childPath=" + childPath\r
-                                               + ", ancestorPath=" + ancestorPath);\r
-\r
-                       return childPath.substring(ancestorPath.length());\r
+                       \r
+                       return ancestor.getURI().relativize(child.getURI()).toString();\r
                } catch (IOException e) {\r
                        throw new SlcException("Cannot extract relative path of " + child\r
                                        + " based on " + ancestor, e);\r
index 068d773fba867dcde769c2b8dd5b3b4ab2e6f2e4..28b75f8dfd4efb5a75c9849b158d747e6568ef3e 100644 (file)
@@ -32,7 +32,7 @@
                <property name="marshaller" ref="slcDefault.castor.marshaller" />\r
                <property name="logXml" value="false" />\r
                <!-- \r
-                       <property name="outputDir" value="D:\dev\test\SLC\SlcReports" />\r
+                       <property name="outputDir" value="/path/to/output/dir" />\r
                -->\r
        </bean>\r
 \r
diff --git a/org.argeo.slc.core/src/main/resources/org/argeo/slc/core/process/spring/applicationContext.xml b/org.argeo.slc.core/src/main/resources/org/argeo/slc/core/process/spring/applicationContext.xml
new file mode 100644 (file)
index 0000000..45bcac9
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
+       default-lazy-init="true">\r
+\r
+       <import
+               resource="classpath:/org/argeo/slc/castor/spring/applicationContext.xml" />
+
+       <bean name="slcDefault.process.fileSlcExecutionNotifier"
+               class="org.argeo.slc.core.process.FileSlcExecutionNotifier">
+               <property name="basePath" value="${slc.workDir}/process" />
+               <property name="marshaller" ref="slcDefault.castor.marshaller" />
+       </bean>
+</beans>
\ No newline at end of file
index 605a28c48be5be9da8b46f0c6ffda71185f41d81..0133bab8851a98402b6707e4ab98fd5f227edf39 100644 (file)
@@ -1,5 +1,5 @@
 # Set root logger level to DEBUG and its only appender to A1.\r
-log4j.rootLogger=INFO, console\r
+log4j.rootLogger=WARN, console\r
 \r
 ## Levels\r
 # Slc\r
@@ -9,12 +9,7 @@ log4j.logger.org.argeo=DEBUG
 log4j.logger.org.exolab.castor=WARN\r
 \r
 # Spring\r
-log4j.logger.org.springframework=INFO\r
-# Hibernate\r
-log4j.logger.org.hibernate=WARN\r
-#log4j.logger.org.hibernate.SQL=TRACE\r
-#log4j.logger.org.hibernate.tool.hbm2ddl=TRACE\r
-#log4j.logger.org.hibernate.type=TRACE\r
+log4j.logger.org.springframework=WARN\r
 \r
 \r
 ## Appenders\r