aboutsummaryrefslogtreecommitdiffstats
path: root/netx/net/sourceforge/jnlp/Log.java
blob: a7aa102bcd6a08aa4290195b29556184878dbac0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package net.sourceforge.jnlp;

import java.io.File;

import net.sourceforge.jnlp.config.DeploymentConfiguration;
import net.sourceforge.jnlp.runtime.JNLPRuntime;

/**
 * This file provides the information required to do logging.
 * 
 * @author Andrew Su (asu@redhat.com, andrew.su@utoronto.ca)
 * 
 */
abstract class Log {

    // Directory where the logs are stored.
    protected static String icedteaLogDir;

    protected static boolean enableLogging = false;
    protected static boolean enableTracing = false;

    // Prepare for logging.
    static {
        DeploymentConfiguration config = JNLPRuntime.getConfiguration();

        // Check whether logging and tracing is enabled.
        enableLogging = Boolean.parseBoolean(config.getProperty(DeploymentConfiguration.KEY_ENABLE_LOGGING));
        enableTracing = Boolean.parseBoolean(config.getProperty(DeploymentConfiguration.KEY_ENABLE_TRACING));

        // 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;
                enableTracing = false;
            }
        }
    }
}