From: Dave B. <bla...@us...> - 2013-07-31 14:13:18
|
Update of /cvsroot/sblim/jsr48-client/src/org/sblim/cimclient/internal/logging In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv3121/src/org/sblim/cimclient/internal/logging Modified Files: Tag: Experimental LogAndTraceBroker.java Log Message: 2651 IOException when tracing the cimxml Index: LogAndTraceBroker.java =================================================================== RCS file: /cvsroot/sblim/jsr48-client/src/org/sblim/cimclient/internal/logging/LogAndTraceBroker.java,v retrieving revision 1.10.2.20 retrieving revision 1.10.2.21 diff -u -d -r1.10.2.20 -r1.10.2.21 --- LogAndTraceBroker.java 26 Jul 2013 17:57:28 -0000 1.10.2.20 +++ LogAndTraceBroker.java 31 Jul 2013 14:13:16 -0000 1.10.2.21 @@ -32,10 +32,12 @@ * 3576396 2012-10-11 blaschke-oss Improve logging of config file name * 3596303 2013-01-04 blaschke-oss windows http response WWW-Authenticate: Negotiate fails * 2652 2013-07-26 blaschke-oss LogAndTraceBroker.setXmlTraceStream should not close previous stream + * 2651 2013-07-31 blaschke-oss IOException when tracing the cimxml */ package org.sblim.cimclient.internal.logging; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -54,6 +56,7 @@ import org.sblim.cimclient.LogAndTraceManager; import org.sblim.cimclient.LogListener; import org.sblim.cimclient.TraceListener; +import org.sblim.cimclient.WBEMConfigurationProperties; import org.sblim.cimclient.internal.util.WBEMConfiguration; import org.sblim.cimclient.internal.util.WBEMConstants; @@ -116,6 +119,8 @@ private OutputStream iXmlTraceStream = null; + private OutputStream iXmlTraceFile = null; + private final String iTHIS_CLASS = this.getClass().getName(); private final String iTHROWABLE = Throwable.class.getName(); @@ -148,6 +153,20 @@ this.iCIMXMLTraceListeners = new ArrayList<CIMXMLTraceListener>(); loadVersionTxt(); registerInternalListeners(); + initXmlTraceFile(); + } + + @Override + protected void finalize() throws Throwable { + try { + if (this.iXmlTraceFile != null && (!this.iXmlTraceFile.equals(System.out)) + && (!this.iXmlTraceFile.equals(System.err))) this.iXmlTraceFile.close(); + } catch (IOException e) { + // bad luck + } finally { + this.iXmlTraceFile = null; + super.finalize(); + } } /** @@ -738,6 +757,39 @@ this.iXmlTraceStream = pStream; } + /* + * Initializes the CIM-XML trace file (sblim.wbem.cimxmlTraceStream) during + * initialization of LogAndTraceBroker - the trace file is used if CIM-XML + * tracing is enabled (sblim.wbem.cimxmlTracing=true) but there is no + * CIM-XML trace stream set via setXmlTraceStream() + */ + private void initXmlTraceFile() { + try { + if (WBEMConfiguration.getGlobalConfiguration().isCimXmlTracingEnabled()) { + String filename = WBEMConfiguration.getGlobalConfiguration().getCimXmlTraceStream(); + if (filename != null && filename.length() > 0 && this.iXmlTraceFile == null + && getXmlTraceStream() == null) { + if (filename.equalsIgnoreCase("System.out")) { + this.iXmlTraceFile = System.out; + } else if (filename.equalsIgnoreCase("System.err")) { + this.iXmlTraceFile = System.err; + } else { + try { + this.iXmlTraceFile = new FileOutputStream(filename); + } catch (IOException e) { + trace(Level.FINE, "Unable to open " + + WBEMConfigurationProperties.CIMXML_TRACE_STREAM + "=" + + filename, e); + } + } + setXmlTraceStream(this.iXmlTraceFile); + } + } + } catch (Exception e) { + // Don't crash for logging + } + } + /** * Analyzes the stack trace and determines from where the * <code>LogAndTraceBroker</code> was called. |