diff options
author | Omair Majid <[email protected]> | 2010-11-18 11:12:10 -0500 |
---|---|---|
committer | Omair Majid <[email protected]> | 2010-11-18 11:12:10 -0500 |
commit | 3f351c0718209878b0a3d880d9757ddca90e447e (patch) | |
tree | 14b93db2b7f2159f57c0ac127be72a52848099c0 /plugin/icedteanp/java/sun/applet/PluginMain.java | |
parent | 16d8875dca7ef93f6c1aea72cf84bb8bb5251722 (diff) |
integrate configurable logging
2010-11-18 Omair Majid <[email protected]>
* netx/net/sourceforge/jnlp/runtime/DeploymentConfiguration.java:
Add KEY_ENABLE_LOGGING.
(loadDefaultProperties): Use KEY_ENABLE_LOGGING.
* netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java: Add
redirectStreams, STDERR_FILE and STDOUT_FILE.
(initialize): Call initializeStreams.
(initializeStreams): New method. Redirects or duplicates stdout and
stderr to the logging files as required.
(setRedirectStreams): New method. Sets whether stdout/stderr streams
should be redirected.
* plugin/icedteanp/java/sun/applet/PluginMain.java:
(PluginMain): Move code for creating logging files into JNLPRuntime.
Call JNLPRuntime.setRedirectStreams to redirect streams.
(TeeOutputStream): Move to its own class.
* netx/net/sourceforge/jnlp/util/TeeOutputStream.java: Moved from
PluginMain into this new class.
Diffstat (limited to 'plugin/icedteanp/java/sun/applet/PluginMain.java')
-rw-r--r-- | plugin/icedteanp/java/sun/applet/PluginMain.java | 73 |
1 files changed, 3 insertions, 70 deletions
diff --git a/plugin/icedteanp/java/sun/applet/PluginMain.java b/plugin/icedteanp/java/sun/applet/PluginMain.java index 8834643..613a8f1 100644 --- a/plugin/icedteanp/java/sun/applet/PluginMain.java +++ b/plugin/icedteanp/java/sun/applet/PluginMain.java @@ -121,25 +121,14 @@ public class PluginMain connect(inPipe, outPipe); + // must be called before JNLPRuntime.initialize() + JNLPRuntime.setRedirectStreams(redirectStreams); + securityContext = new PluginAppletSecurityContext(0); securityContext.prePopulateLCClasses(); securityContext.setStreamhandler(streamHandler); AppletSecurityContextManager.addContext(0, securityContext); - String logDir = JNLPRuntime.getConfiguration().getProperty(DeploymentConfiguration.KEY_USER_LOG_DIR); - try { - File errFile = new File(logDir, PLUGIN_STDERR_FILE); - errFile.getParentFile().mkdirs(); - File outFile = new File(logDir, PLUGIN_STDOUT_FILE); - outFile.getParentFile().mkdirs(); - - System.setErr(new TeeOutputStream(new FileOutputStream(errFile), System.err)); - System.setOut(new TeeOutputStream(new FileOutputStream(outFile), System.out)); - } catch (Exception e) { - PluginDebug.debug("Unable to redirect streams"); - e.printStackTrace(); - } - PluginAppletViewer.setStreamhandler(streamHandler); PluginAppletViewer.setPluginCallRequestFactory(new PluginCallRequestFactory()); @@ -244,61 +233,5 @@ public class PluginMain return auth; } } - - /** - * Behaves like the 'tee' command, sends output to both actual std stream and a - * file - */ - class TeeOutputStream extends PrintStream { - - // Everthing written to TeeOutputStream is written to this file - PrintStream logFile; - - public TeeOutputStream(FileOutputStream fileOutputStream, - PrintStream stdStream) { - super(stdStream); - logFile = new PrintStream(fileOutputStream); - } - - @Override - public boolean checkError() { - boolean thisError = super.checkError(); - boolean fileError = logFile.checkError(); - - return thisError || fileError; - } - - @Override - public void close() { - logFile.close(); - super.close(); - } - - @Override - public void flush() { - logFile.flush(); - super.flush(); - } - - /* - * The big ones: these do the actual writing - */ - - @Override - public void write(byte[] buf, int off, int len) { - logFile.write(buf, off, len); - - if (!redirectStreams) - super.write(buf, off, len); - } - - @Override - public void write(int b) { - logFile.write(b); - - if (!redirectStreams) - super.write(b); - } - } } |