aboutsummaryrefslogtreecommitdiffstats
path: root/netx/net/sourceforge/jnlp/util/logging/LogConfig.java
diff options
context:
space:
mode:
authorJiri Vanek <[email protected]>2013-09-25 18:50:18 +0200
committerJiri Vanek <[email protected]>2013-09-25 18:50:18 +0200
commit19e74fe5dacd03e0cb5582f840e15262e39fe24f (patch)
tree38ffc4f47f7641f8d20ba0e0e8a97a97ffb1db64 /netx/net/sourceforge/jnlp/util/logging/LogConfig.java
parentfcd5c4c69fc5ea84b04f309eb40e295eab921fd8 (diff)
Introduced logging bottleneck
Diffstat (limited to 'netx/net/sourceforge/jnlp/util/logging/LogConfig.java')
-rw-r--r--netx/net/sourceforge/jnlp/util/logging/LogConfig.java156
1 files changed, 156 insertions, 0 deletions
diff --git a/netx/net/sourceforge/jnlp/util/logging/LogConfig.java b/netx/net/sourceforge/jnlp/util/logging/LogConfig.java
new file mode 100644
index 0000000..5e1644c
--- /dev/null
+++ b/netx/net/sourceforge/jnlp/util/logging/LogConfig.java
@@ -0,0 +1,156 @@
+/* LogConfig.java
+ Copyright (C) 2011, 2013 Red Hat, Inc.
+
+ This file is part of IcedTea.
+
+ IcedTea is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, version 2.
+
+ IcedTea is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with IcedTea; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version.
+ */
+package net.sourceforge.jnlp.util.logging;
+
+import java.io.File;
+import javax.naming.ConfigurationException;
+
+import net.sourceforge.jnlp.config.DeploymentConfiguration;
+import net.sourceforge.jnlp.runtime.JNLPRuntime;
+
+/**
+ * This file provides the information required to do logging.
+ *
+ */
+public class LogConfig {
+
+ // Directory where the logs are stored.
+ private String icedteaLogDir;
+ private boolean enableLogging;
+ private boolean enableHeaders;
+ private boolean logToFile;
+ private boolean logToStreams;
+ private boolean logToSysLog;
+
+ private static LogConfig logConfig;
+
+ public LogConfig() {
+ try {
+ DeploymentConfiguration config = JNLPRuntime.getConfiguration();
+ if (config.getRaw().isEmpty()){
+ config = new DeploymentConfiguration();//JNLPRuntime.getConfiguration() cannotbe loaded time
+ config.load(); //read one prior
+ //todo fix JNLPRuntime.getConfiguration(); to be correct singleton - not easy task!
+ }
+
+ // Check whether logging and tracing is enabled.
+ enableLogging = Boolean.parseBoolean(config.getProperty(DeploymentConfiguration.KEY_ENABLE_LOGGING));
+ //enagle disable headers
+ enableHeaders = Boolean.parseBoolean(config.getProperty(DeploymentConfiguration.KEY_ENABLE_LOGGING_HEADERS));
+ //enable/disable individual channels
+ logToFile = Boolean.parseBoolean(config.getProperty(DeploymentConfiguration.KEY_ENABLE_LOGGING_TOFILE));
+ logToStreams = Boolean.parseBoolean(config.getProperty(DeploymentConfiguration.KEY_ENABLE_LOGGING_TOSTREAMS));
+ logToSysLog = Boolean.parseBoolean(config.getProperty(DeploymentConfiguration.KEY_ENABLE_LOGGING_TOSYSTEMLOG));
+
+ // Get log directory, create it if it doesn't exist. If unable to create and doesn't exist, don't log.
+ icedteaLogDir = config.getProperty(DeploymentConfiguration.KEY_USER_LOG_DIR);
+ if (icedteaLogDir != null) {
+ File f = new File(icedteaLogDir);
+ if (f.isDirectory() || f.mkdirs()) {
+ icedteaLogDir += File.separator;
+ } else {
+ enableLogging = false;
+ }
+ }
+ } catch (ConfigurationException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static LogConfig getLogConfig() {
+ if (logConfig == null) {
+ logConfig = new LogConfig();
+ }
+ return logConfig;
+ }
+
+ public String getIcedteaLogDir() {
+ return icedteaLogDir;
+ }
+
+ public boolean isEnableLogging() {
+ return enableLogging;
+ }
+
+ public boolean isLogToFile() {
+ return logToFile;
+ }
+
+ public boolean isLogToStreams() {
+ return logToStreams;
+ }
+
+ public boolean isLogToSysLog() {
+ return logToSysLog;
+ }
+
+ public boolean isEnableHeaders() {
+ return enableHeaders;
+ }
+
+
+
+ //package private setters for testing
+
+ void setEnableHeaders(boolean enableHeaders) {
+ this.enableHeaders = enableHeaders;
+ }
+
+ void setEnableLogging(boolean enableLogging) {
+ this.enableLogging = enableLogging;
+ }
+
+ void setIcedteaLogDir(String icedteaLogDir) {
+ this.icedteaLogDir = icedteaLogDir;
+ }
+
+ void setLogToFile(boolean logToFile) {
+ this.logToFile = logToFile;
+ }
+
+ void setLogToStreams(boolean logToStreams) {
+ this.logToStreams = logToStreams;
+ }
+
+ void setLogToSysLog(boolean logToSysLog) {
+ this.logToSysLog = logToSysLog;
+ }
+
+
+
+
+}