/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.highcharts.export.util;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;

/**
 *
 * @author gert
 */
public class TempDir {

	public static Path tmpDir;
	public static Path outputDir;
	public static Path phantomJsDir;

	public TempDir() throws IOException {
		tmpDir = Files.createTempDirectory("export");

		// Delete this directory on deletion of the JVM
		tmpDir.toFile().deleteOnExit();

		outputDir = Files.createDirectory(Paths.get(tmpDir.toString(), "output"));
		outputDir.toFile().deleteOnExit();
		
		phantomJsDir = Files.createDirectory(Paths.get(tmpDir.toString(), "phantomjs"));
		phantomJsDir.toFile().deleteOnExit();

		Runtime.getRuntime().addShutdownHook(new Thread() {
		    public void run() {
		        FileUtils.deleteQuietly(tmpDir.toFile());
		    }
		});
		
		System.out.println("Highcharts Export Server using " +TempDir.getTmpDir() + " as TEMP folder.");
	}

	public static Path getTmpDir() {
		return tmpDir;
	}

	public static Path getOutputDir() {
		return outputDir;
	}

	public static Path getPhantomJsDir() {
		return phantomJsDir;
	}

	public static String getDownloadLink(String filename) {
		filename = FilenameUtils.getName(filename);
		String link = "files/" + filename;
		return link;
	}



}

@@ -363,16 +363,48 @@
 IOUtils;
+%0Aimport org.apache.log4j.Logger;
 %0A%0A/**%0A *
@@ -542,16 +542,86 @@
 JsDir;%0A%0A
+    protected static Logger logger = Logger.getLogger(%22tempdir%22);%0A%09%0A%09%0A
 %09public 
@@ -1181,26 +1181,20 @@
 %09%0A%09%09
-System.out.println
+logger.debug
 (%22Hi

Use logger rather than System.out.println()