Commit b7292040 authored by urbant's avatar urbant
Browse files

Improved logging of XmlDiff (by Nikolay)

parent 7b1c60c8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ public class LogUtil {
			record.setSourceMethodName(caller.getMethodName());
		}
		logger.log(record);
		
	}
	
	public void severe(Object... args) {
+47 −27
Original line number Diff line number Diff line
@@ -45,15 +45,18 @@ public class XmlDiff {
	public static LogUtil logger = null;
	static {
		logger = new LogUtil(Logger.getLogger("org.etsi.mts.ttcn.part9.xmldiff"));
		logger.logger.setLevel(Level.FINE);
		try {
			FileHandler fh = new FileHandler("XmlDiff.log", true);
			fh.setLevel(Level.INFO);
			fh.setLevel(Level.FINE);
			logger.logger.addHandler(fh);
		} catch (SecurityException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		System.err.println("XmlDiff class loaded");
		
	}
	
	public static class IgnoreSchemePrefix implements DifferenceListener {
@@ -113,6 +116,11 @@ public class XmlDiff {
	 * 
	 */
	public XmlDiff(File file, String[] xsdFileNames, String[] xsdSearchPath) {
		System.err.println("XmlDiff constructor called");
		logger.debug("Reference file: ", file, 
				", xsd file names: ", (xsdFileNames == null)? "null" : Arrays.toString(xsdFileNames),
				", xsd search path: ", (xsdSearchPath == null)? "null" : Arrays.toString(xsdSearchPath));		
		try {
			this.referenceXmlFile = file;
			if (!this.referenceXmlFile.exists()) {
				logger.severe("No such file: ", this.referenceXmlFile.getAbsolutePath());
@@ -140,6 +148,12 @@ public class XmlDiff {
			if (xsdFiles.size() > 0) {
				addXmlSchemas();
			}
		} catch(Throwable err) {
			err.printStackTrace();
			throw err;
		} finally {
			System.err.println("XmlDiff constructor finished");
		}
	}

	/** Compare an XML document against the reference one.
@@ -256,6 +270,12 @@ public class XmlDiff {
		List<String> missing = new ArrayList<String>();
		if (xsdSearchPath == null || xsdSearchPath.length == 0) {
			for (String name : xsdFileNames) {
				if (name == null) {
					logger.severe("XSD file name is nul!!!");
					continue;
				} else {
					logger.debug("Looking for XSD file ", name);
				}
				File guess = new File(name);
				if (guess.exists()) {
					xsdFiles.add(guess);