From f79469b34e0e44b77124be22d01f7963fdb387f4 Mon Sep 17 00:00:00 2001
From: Peter van 't Hof <p.j.van_t_hof@lumc.nl>
Date: Tue, 28 Jul 2015 11:52:47 +0200
Subject: [PATCH] 1 level nested output_dir now allowed for log file

---
 .../nl/lumc/sasc/biopet/core/PipelineCommand.scala | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/PipelineCommand.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/PipelineCommand.scala
index 52c4a7397..8654e413d 100644
--- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/PipelineCommand.scala
+++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/PipelineCommand.scala
@@ -64,13 +64,19 @@ trait PipelineCommand extends MainCommand with GatkLogging {
     }
     for (t <- 0 until argsSize) {
       if (args(t) == "--outputDir" || args(t) == "-outDir") {
-        throw new IllegalArgumentException("Commandline argument is deprecated, should use config for this now")
+        throw new IllegalArgumentException("Commandline argument is deprecated, should use config for this now or use: -cv output_dir=<Path to output dir>")
       }
     }
 
-    val logDir: File = new File(Config.global.map.getOrElse("output_dir", "./").toString + File.separator + ".log")
-    logDir.mkdirs()
-    val logFile = new File(logDir, "biopet." + BiopetQCommandLine.timestamp + ".log")
+    val logFile = {
+      val pipelineName = this.getClass.getSimpleName.toLowerCase.split("""\$""").head
+      val pipelineConfig = Config.global.map.getOrElse(pipelineName, Map()).asInstanceOf[Map[String, Any]]
+      val pipelineOutputDir = new File(Config.global.map.getOrElse("output_dir", pipelineConfig.getOrElse("output_dir", "./")).toString)
+      val logDir: File = new File(pipelineOutputDir, ".log")
+      logDir.mkdirs()
+      new File(logDir, "biopet." + BiopetQCommandLine.timestamp + ".log")
+    }
+
     val a = new WriterAppender(new PatternLayout("%-5p [%d] [%C{1}] - %m%n"), new PrintWriter(logFile))
     logger.addAppender(a)
 
-- 
GitLab