aboutsummaryrefslogtreecommitdiffstats
path: root/netx/net/sourceforge/jnlp
diff options
context:
space:
mode:
authorJiri Vanek <[email protected]>2013-11-29 11:44:11 +0100
committerJiri Vanek <[email protected]>2013-11-29 11:44:11 +0100
commitb734ac62fbdbdaa855983ebea07f7b92d0a02c33 (patch)
treefde1b807ff172e7e7d8e949232395d577f1a723e /netx/net/sourceforge/jnlp
parentde9b5d773fb4adec13673ca26cb61b534e6c5012 (diff)
Enabled file logging in plugin, user enabled to choose logs dir
Diffstat (limited to 'netx/net/sourceforge/jnlp')
-rw-r--r--netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java54
-rw-r--r--netx/net/sourceforge/jnlp/resources/Messages.properties4
-rw-r--r--netx/net/sourceforge/jnlp/util/logging/FileLog.java23
3 files changed, 76 insertions, 5 deletions
diff --git a/netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java b/netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java
index bee0a53..68d34d9 100644
--- a/netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java
+++ b/netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java
@@ -23,13 +23,20 @@ import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.Box;
+import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
+import javax.swing.JTextField;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+import net.sourceforge.jnlp.config.Defaults;
import net.sourceforge.jnlp.config.DeploymentConfiguration;
import net.sourceforge.jnlp.runtime.Translator;
import net.sourceforge.jnlp.util.logging.LogConfig;
@@ -74,7 +81,41 @@ public class DebuggingPanel extends NamedBorderPanel implements ItemListener {
private void addComponents() {
GridBagConstraints c = new GridBagConstraints();
- JLabel debuggingDescription = new JLabel("<html>" + Translator.R("CPDebuggingDescription") + "<hr /><br /></html>");
+
+ final JLabel debuggingDescription = new JLabel("<html>" + Translator.R("CPDebuggingDescription") + "<hr /><br /></html>");
+ final JLabel logsDestinationTitle = new JLabel(Translator.R("CPFilesLogsDestDir")+": ");
+ final JTextField logsDestination = new JTextField(config.getProperty(DeploymentConfiguration.KEY_USER_LOG_DIR));
+ logsDestination.getDocument().addDocumentListener(new DocumentListener() {
+
+
+ @Override
+ public void insertUpdate(DocumentEvent e) {
+ save();
+ }
+
+ @Override
+ public void removeUpdate(DocumentEvent e) {
+ save();
+ }
+
+ @Override
+ public void changedUpdate(DocumentEvent e) {
+ save();
+
+ }
+
+ private void save() {
+ config.setProperty(DeploymentConfiguration.KEY_USER_LOG_DIR, logsDestination.getText());
+ }
+ });
+ final JButton logsDestinationReset = new JButton(Translator.R("CPFilesLogsDestDirResert"));
+ logsDestinationReset.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ logsDestination.setText(Defaults.getDefaults().get(DeploymentConfiguration.KEY_USER_LOG_DIR).getDefaultValue());
+ }
+ });
JCheckBox[] debuggingOptions = {
new JCheckBox(Translator.R("DPEnableLogging")),
@@ -130,9 +171,18 @@ public class DebuggingPanel extends NamedBorderPanel implements ItemListener {
debuggingOptions[i].addItemListener(this);
add(debuggingOptions[i], c);
-
+ if (i == 2) {
+ c.gridx++;
+ add(logsDestinationTitle, c);
+ c.gridx++;
+ add(logsDestination, c);
+ c.gridx++;
+ add(logsDestinationReset, c);
+ c.gridx-=3;
+ }
}
+
for (int j = 0; j < javaConsoleItems.length; j++) {
consoleComboBox.addItem(javaConsoleItems[j]);
if (config.getProperty(DeploymentConfiguration.KEY_CONSOLE_STARTUP_MODE).equals(javaConsoleItems[j].getValue())) {
diff --git a/netx/net/sourceforge/jnlp/resources/Messages.properties b/netx/net/sourceforge/jnlp/resources/Messages.properties
index 5cea7d2..2e5fb82 100644
--- a/netx/net/sourceforge/jnlp/resources/Messages.properties
+++ b/netx/net/sourceforge/jnlp/resources/Messages.properties
@@ -402,11 +402,13 @@ APSExceptionInstruction=Separate each entry with a semicolon.
# Control Panel - DebugginPanel
CPDebuggingPossibilites=Logging outputs
-DPEnableLogging=Enable logging
+DPEnableLogging=Enable debugging
DPEnableLoggingHint=When this switch is on, then also debug messages are logged. Same as -verbose or ICEDTEAPLUGIN_DEBUG=true
DPEnableHeaders=Enable headers
DPEnableHeadersHint=When this switch is on, each logged message have header with additional information like user, place in code and time
DPEnableFile=Enable logging to file
+CPFilesLogsDestDir=File logs directory
+CPFilesLogsDestDirResert=Reset to default
DPEnableFileHint=output messages will be saved to file in your {0} directory
DPEnableStds=Enable logging to standard outputs
DPEnableStdsHint=messages will be printed to standard outputs
diff --git a/netx/net/sourceforge/jnlp/util/logging/FileLog.java b/netx/net/sourceforge/jnlp/util/logging/FileLog.java
index 05b079a..3ac048b 100644
--- a/netx/net/sourceforge/jnlp/util/logging/FileLog.java
+++ b/netx/net/sourceforge/jnlp/util/logging/FileLog.java
@@ -38,6 +38,8 @@ package net.sourceforge.jnlp.util.logging;
import java.io.File;
import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
import java.util.logging.FileHandler;
import java.util.logging.Formatter;
import java.util.logging.Level;
@@ -50,17 +52,20 @@ import net.sourceforge.jnlp.util.FileUtils;
*
*/
public final class FileLog implements SingleStreamLogger {
+ private static SimpleDateFormat fileLogNameFormatter = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss.S");
+ /**"Tue Nov 19 09:43:50 CET 2013"*/
+ private static SimpleDateFormat pluginSharedFormatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss ZZZ yyyy");
private final Logger impl;
private final FileHandler fh;
private static final String defaultloggerName = "IcedTea-Web file-logger";
public FileLog() {
- this(defaultloggerName, LogConfig.getLogConfig().getIcedteaLogDir() + "itw-" + java.lang.System.currentTimeMillis() + ".log", false);
+ this(false);
}
public FileLog(boolean append) {
- this(defaultloggerName, LogConfig.getLogConfig().getIcedteaLogDir() + "itw-" + java.lang.System.currentTimeMillis() + ".log", append);
+ this(defaultloggerName, LogConfig.getLogConfig().getIcedteaLogDir() + "itw-javantx-" + getStamp() + ".log", append);
}
@@ -104,4 +109,18 @@ public final class FileLog implements SingleStreamLogger {
public void close(){
fh.close();
}
+
+ private static String getStamp() {
+ return fileLogNameFormatter.format(new Date());
+ }
+
+ public static SimpleDateFormat getFileLogNameFormatter() {
+ return fileLogNameFormatter;
+ }
+
+ public static SimpleDateFormat getPluginSharedFormatter() {
+ return pluginSharedFormatter;
+ }
+
+
}