Return-Path: Delivered-To: apmail-db-jdo-dev-archive@www.apache.org Received: (qmail 5837 invoked from network); 18 Aug 2005 15:25:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 18 Aug 2005 15:25:15 -0000 Received: (qmail 3291 invoked by uid 500); 18 Aug 2005 15:25:15 -0000 Mailing-List: contact jdo-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jdo-dev@db.apache.org Delivered-To: mailing list jdo-dev@db.apache.org Received: (qmail 3278 invoked by uid 99); 18 Aug 2005 15:25:15 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Aug 2005 08:25:15 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [212.224.30.66] (HELO service-01.spree.de) (212.224.30.66) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Aug 2005 08:25:33 -0700 Received: from [172.16.1.19] (rio.spree.de [172.16.1.19]) (authenticated bits=0) by service-01.spree.de (8.13.4/8.13.4/Debian-3) with ESMTP id j7IFP6Qk013785 for ; Thu, 18 Aug 2005 17:25:07 +0200 Message-ID: <4304A8EF.1030800@spree.de> Date: Thu, 18 Aug 2005 17:27:43 +0200 From: Michael Watzek Organization: Tech@Spree GmbH User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: jdo-dev@db.apache.org Subject: Patch implementing logging proposal Content-Type: multipart/mixed; boundary="------------080808010508080402080609" X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N --------------080808010508080402080609 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, please find the attached patch implementing the logging proposal. After applying the patch and before running the TCK, make sure to reinstall the schema or to copy "derby.properties" to "target/database/derby". That file contains a property specifying where to write the Derby logging file. I changed the logging level in order to see SQL statements in that file. This is the output of "svn status" in my workspace: tck20>svn status A test/java/org/apache/jdo/tck/util/TCKFileAppender.java M test/java/org/apache/jdo/tck/util/BatchTestRunner.java M test/conf/logging.properties M test/conf/derby.properties A test/conf/log4j.properties M project.properties M maven.xml Regards, Michael -- ------------------------------------------------------------------- Michael Watzek Tech@Spree Engineering GmbH mailto:mwa.tech@spree.de Buelowstr. 66 Tel.: ++49/30/235 520 36 10783 Berlin - Germany Fax.: ++49/30/217 520 12 http://www.spree.de/ ------------------------------------------------------------------- --------------080808010508080402080609 Content-Type: text/plain; name="logging.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="logging.patch" Index: test/java/org/apache/jdo/tck/util/TCKFileAppender.java =================================================================== --- test/java/org/apache/jdo/tck/util/TCKFileAppender.java (revision 0) +++ test/java/org/apache/jdo/tck/util/TCKFileAppender.java (revision 0) @@ -0,0 +1,54 @@ +/* + * Copyright 2005 The Apache Software Foundation. + * + * Licensed 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.jdo.tck.util; + +import java.io.IOException; + +import org.apache.log4j.FileAppender; +import org.apache.log4j.Layout; + +/** + * FileAppender appends log events to a file. + */ +public class TCKFileAppender extends FileAppender { + + /** + * Delegates to super constructor. + */ + public TCKFileAppender() {} + + public TCKFileAppender(Layout layout, String filename, boolean append, + boolean bufferedIO, int bufferSize) throws IOException { + super(layout, filename, append, bufferedIO, bufferSize); + } + + public TCKFileAppender(Layout layout, String filename, boolean append) + throws IOException { + super(layout, filename, append); + } + + public TCKFileAppender(Layout layout, String filename) throws IOException { + this(layout, filename, true); + } + + public synchronized void setFile(String fileName, boolean append, boolean bufferedIO, int bufferSize) + throws IOException { + String changedFileName = BatchTestRunner.changeFileNameCreateDirectory(fileName); + super.setFile(changedFileName, append, bufferedIO, bufferSize); + } +} + Property changes on: test/java/org/apache/jdo/tck/util/TCKFileAppender.java ___________________________________________________________________ Name: svn:executable + * Index: test/java/org/apache/jdo/tck/util/BatchTestRunner.java =================================================================== --- test/java/org/apache/jdo/tck/util/BatchTestRunner.java (revision 233318) +++ test/java/org/apache/jdo/tck/util/BatchTestRunner.java (working copy) @@ -17,16 +17,13 @@ package org.apache.jdo.tck.util; import java.io.File; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; -import java.text.SimpleDateFormat; import java.util.Arrays; -import java.util.Date; import junit.framework.Test; import junit.framework.TestResult; @@ -57,7 +54,7 @@ /** Redirect System.out and System.err to an ConsoleFileOutput instance. */ static { - if (!Boolean.getBoolean("noLogFile")) { + if (!Boolean.getBoolean("no.log.file")) { PrintStream printStream = new PrintStream(new ConsoleFileOutput()); System.setErr(printStream); System.setOut(printStream); @@ -191,34 +188,17 @@ private static class ConsoleFileOutput extends OutputStream { - private static String outDir = "logs"; - private static String fileNameSuffix = ".txt"; - private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd-HHmmss"); private PrintStream systemOut = System.out; private FileOutputStream fileOut; private ConsoleFileOutput() { - String identityType = System.getProperty("jdo.tck.identitytype"); - String db = System.getProperty("jdo.tck.database"); - String testConfig = System.getProperty("jdo.tck.cfg"); - if (identityType.equals("applicationidentity")) - identityType = "app"; - else identityType = "dsid"; - testConfig = testConfig.substring(0, testConfig.indexOf('.')); - String fileName = simpleDateFormat.format(new Date()) + "-" - + db + "-" - + identityType + "-" - + testConfig - + fileNameSuffix; - File dir = new File(outDir); - if (!dir.exists()) { - dir.mkdir(); - } - + String fileName = null; try { - fileOut = new FileOutputStream(new File(dir, fileName)); - } catch (FileNotFoundException e) { - System.err.println("Cannot create log file "+fileName+". "+e); + fileName = getFileNameCreateDirectory(); + this.fileOut = new FileOutputStream(fileName); + } catch (IOException e) { + if (fileName!=null) + System.err.println("Cannot create log file "+fileName+". "+e); } } @@ -246,4 +226,85 @@ this.fileOut.flush(); } } + + public static String getFileNameCreateDirectory() throws IOException { + return changeFileNameCreateDirectory(".txt"); + } + + public static String changeFileNameCreateDirectory(String fileName) throws IOException { + String directory = getSysPropertyAsPartialFileName("jdo.tck.log.directory", File.separatorChar); + if (directory!=null) { + File dir = new File(directory); + if (!dir.exists() && + !dir.mkdirs()) { + throw new IOException("Cannot create directory "+dir); + } + } + + String db = getSysPropertyAsPartialFileName("jdo.tck.database"); + + String identityType = getSysPropertyAsPartialFileName("jdo.tck.identitytype"); + if (identityType!=null) { + if (identityType.equals("applicationidentity")) { + identityType = "app"; + } else { + identityType = "dsid"; + } + } + + String configuration = getSysPropertyAsPartialFileName("jdo.tck.cfg"); + if (configuration!=null) { + int index = configuration.indexOf('.'); + if (index!=-1) { + configuration = configuration.substring(0, index); + } + } + + directory = fixPartialFileName(directory); + db = fixPartialFileName(db, '-', + new String[]{identityType, configuration, fileName}); + identityType = fixPartialFileName(identityType, '-', + new String[]{configuration, fileName}); + configuration = fixPartialFileName(configuration, '-', + new String[]{fileName}); + + return directory + db + identityType + configuration + fileName; + } + + private static String getSysPropertyAsPartialFileName(String property) { + return getSysPropertyAsPartialFileName(property, (char)0); + } + + private static String getSysPropertyAsPartialFileName(String property, char trailingChar) { + String result = System.getProperty(property); + if (result!=null && + trailingChar!=0) { + result += trailingChar; + } + return result; + } + + private static String fixPartialFileName(String str) { + if (str==null) { + str = ""; + } + return str; + } + + private static String fixPartialFileName(String str, char c, + String[] values) { + str = fixPartialFileName(str); + if (!str.equals("")) { + for (int i = 0; i < values.length; i++) { + String value = values[i]; + if (value!=null && + !value.equals("") && + !value.startsWith(".")) { + str += c; + break; + } + } + } + return str; + } } Index: test/conf/logging.properties =================================================================== --- test/conf/logging.properties (revision 233318) +++ test/conf/logging.properties (working copy) @@ -41,26 +41,3 @@ handlers = java.util.logging.ConsoleHandler java.util.logging.ConsoleHandler.level = FINEST - - -###################### -# JPOX logging properties -###################### - -# Define the destination and format of our logging -log4j.appender.A1=org.apache.log4j.FileAppender -log4j.appender.A1.File=jpox.log -log4j.appender.A1.layout=org.apache.log4j.PatternLayout -log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss,SSS} (%t) %-5p [%c] - %m%n - -# JPOX Categories -log4j.category.JPOX.JDO=INFO, A1 -log4j.category.JPOX.Cache=INFO, A1 -log4j.category.JPOX.MetaData=INFO, A1 -log4j.category.JPOX.General=DEBUG, A1 -log4j.category.JPOX.Utility=INFO, A1 -log4j.category.JPOX.Transaction=INFO, A1 -log4j.category.JPOX.RDBMS=DEBUG, A1 - -log4j.category.JPOX.Enhancer=INFO, A1 -log4j.category.JPOX.SchemaTool=INFO, A1 Index: test/conf/derby.properties =================================================================== --- test/conf/derby.properties (revision 233318) +++ test/conf/derby.properties (working copy) @@ -1,2 +1,46 @@ -# This flag must be set on Mac OSX -#derby.storage.fileSyncTransactionLog=true +# This flag must be set on Mac OSX +#derby.storage.fileSyncTransactionLog=true + +#When this property is set to true, Derby writes the query plan information +#into the derby.log file for all executed queries. +#Default: false +#derby.language.logQueryPlan=true + +#When this property is set to true, Derby writes the text and parameter values +#of all executed statements to the information log at the beginning of +#execution. It also writes information about commits and rollbacks. +#Information includes the time and thread number. +#Default: false +derby.language.logStatementText=true + +#Specifies name of the file to which the error log is written. +#If the file name is relative, it is taken as relative to the system directory. +#If this property is set, the derby.stream.error.method and +#derby.stream.error.field properties are ignored. +#Default: derby.log +derby.stream.error.file=../../logs/database/derby.log + +#Specifies which errors are logged to the Derby error log +#(typically the derby.log file). In test environments, use the setting +#derby.stream.error.logSeverityLevel=0 so that all problems are reported. +#Any error raised in a Derby system is given a level of severity. +#This property indicates the minimum severity necessary for an error to appear +#in the error log. The severities are defined in the class +#org.apache.derby.types.ExceptionSeverity. +#The higher the number, the more severe the error. +#20000: Errors that cause the statement to be rolled back, +#for example syntax errors and constraint violations. +#30000: Errors that cause the transaction to be rolled back, +#for example deadlocks. +#40000: Errors that cause the connection to be closed. +#50000: Errors that shut down the Derby system. +#Default: 40000 +#derby.stream.error.logSeverityLevel=0 + +#Specifies whether to append to or destroy and re-create the derby.log file, +#which is used to record error and other information +#when Derby starts up in a JVM. +#You can set this property even if the file does not yet exist; +#Derby creates the file. +#Default: false +derby.infolog.append=true Index: test/conf/log4j.properties =================================================================== --- test/conf/log4j.properties (revision 0) +++ test/conf/log4j.properties (revision 0) @@ -0,0 +1,40 @@ +# +# Copyright 2005 The Apache Software Foundation. +# +# Licensed 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. + +########################### +# JPOX logging properties # +########################### + +# JPOX appenders +log4j.appender.JPOX=org.apache.jdo.tck.util.TCKFileAppender +log4j.appender.JPOX.File=jpox.txt +log4j.appender.JPOX.layout=org.apache.log4j.PatternLayout +log4j.appender.JPOX.layout.ConversionPattern=%d{HH:mm:ss,SSS} (%t) %-5p [%c] - %m%n + +# JPOX loggers +log4j.logger.JPOX=INFO, JPOX +#log4j.logger.JPOX.JDO=INFO, JPOX +#log4j.logger.JPOX.Cache=INFO, JPOX +#log4j.logger.JPOX.MetaData=INFO, JPOX +#log4j.logger.JPOX.General=DEBUG, JPOX +#log4j.logger.JPOX.Utility=INFO, JPOX +#log4j.logger.JPOX.Transaction=INFO, JPOX +#log4j.logger.JPOX.RDBMS=INFO, JPOX + +log4j.logger.JPOX.Enhancer=INFO, JPOX +log4j.logger.JPOX.SchemaTool=INFO, JPOX + +# C3P0 loggers +log4j.logger.com.mchange.v2=INFO, JPOX Property changes on: test/conf/log4j.properties ___________________________________________________________________ Name: svn:executable + * Index: project.properties =================================================================== --- project.properties (revision 233318) +++ project.properties (working copy) @@ -21,7 +21,7 @@ # iut properties file iut.runtck.properties = iut.properties -iut.runtck.sysproperties = -Dderby.system.home=${jdo.tck.testdir}/database/${jdo.tck.database} -Dlog4j.configuration=file:${basedir}/test/conf/logging.properties +iut.runtck.sysproperties = -Dderby.system.home=${jdo.tck.testdir}/database/${jdo.tck.database} # Flags indicating whether IUT supports application/datastore identity iut.applicationidentity.supported = yes @@ -32,7 +32,7 @@ iut.enhancer.main = ${jdo.enhancer.main} iut.enhancer.options = -v -d "${iut.enhanced.dir}" iut.enhancer.args = ${jdo.tck.jdometadata.files} -iut.enhancer.sysproperties = -Dlog4j.configuration=file:${basedir}/test/conf/logging.properties +iut.enhancer.sysproperties = iut.enhancer.sourcepath = ${jdo.tck.testclasses.dir}${path.separator}${jdo.jdoapi.jarfile}${path.separator}${junit.jarfile}${path.separator}${log4j.jarfile} iut.enhancer.classpath = ${jpox.enhancer.jarfile}${path.separator}${jpox.jdori.jarfile}${path.separator}${jdo.jdoapi.jarfile}${path.separator}${log4j.jarfile}${path.separator}${bcel.jarfile}${path.separator}${jdo.tck.testclasses.dir} @@ -49,7 +49,10 @@ jdo.tck.testclasses.dir = ${maven.build.dir}/classes jdo.tck.testdir = ${maven.build.dir} jdo.tck.resultprinterclass = org.apache.jdo.tck.util.BatchResultPrinter -database.runtck.sysproperties = -Dderby.system.home=${jdo.tck.testdir}/database/${jdo.tck.database} -Dlog4j.configuration=file:${basedir}/test/conf/logging.properties +jdo.tck.log.directory = logs +jdo.tck.log.directory.database = ${maven.build.dir}/${jdo.tck.log.directory}/database +jdo.tck.log.directory.enhancer = ${maven.build.dir}/${jdo.tck.log.directory}/enhancer +database.runtck.sysproperties = -Dderby.system.home=${jdo.tck.testdir}/database/${jdo.tck.database} jdo.runtck.sysproperties = -Xmx512m # dependencies @@ -307,6 +310,9 @@ org/apache/jdo/tck/api/instancecallbacks/NoAccessToFieldsAfterPredelete.class \ org/apache/jdo/tck/api/instancecallbacks/TestParts.class +jdo.tck.util.enhancer.sources = \ + org/apache/jdo/tck/util/TCKFileAppender.java + jdo.tck.jdometadata.files = \ org/apache/jdo/tck/pc/company/package.jdo \ org/apache/jdo/tck/pc/fieldtypes/AllTypes.jdo \ Index: maven.xml =================================================================== --- maven.xml (revision 233318) +++ maven.xml (working copy) @@ -142,6 +142,7 @@ + @@ -197,12 +198,16 @@ + + + + Run all configurations on iut @@ -228,12 +233,16 @@ + + + + Run all configurations on jdori @@ -296,6 +305,8 @@ value="${jdo.tck.cfg}"/> + @@ -341,6 +352,8 @@ value="${jdo.tck.cfg}"/> + @@ -381,10 +394,17 @@ + + + + + + @@ -410,6 +430,12 @@ dir="${jdo.tck.enhanced.dir}/${jdo.tck.identitytype}" classname="${iut.enhancer.main}" classpathref="this.enhance.class.path"> + + + @@ -432,6 +458,12 @@ dir="${jdo.tck.enhanced.dir}/${jdo.tck.identitytype}" classname="${jdo.enhancer.main}" classpathref="this.enhance.class.path"> + + + @@ -577,6 +609,7 @@ + --------------080808010508080402080609--