Skip to content
Snippets Groups Projects
Commit 62ab9637 authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Force logging to a file

parent c67a1b6e
No related branches found
No related tags found
No related merge requests found
......@@ -15,10 +15,12 @@
*/
package nl.lumc.sasc.biopet.core
import org.apache.log4j.{ PatternLayout, Appender, WriterAppender, FileAppender }
import org.broadinstitute.gatk.queue.util.{ Logging => GatkLogging }
import java.io.File
import java.io.{ PrintWriter, File }
import nl.lumc.sasc.biopet.core.config.Config
import nl.lumc.sasc.biopet.core.workaround.BiopetQCommandLine
import scala.collection.JavaConversions._
/** Wrapper around executable from Queue */
trait PipelineCommand extends MainCommand with GatkLogging {
......@@ -64,9 +66,18 @@ trait PipelineCommand extends MainCommand with GatkLogging {
}
}
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 a = new WriterAppender(new PatternLayout("%-5p [%d] [%C{1}] - %m%n"), new PrintWriter(logFile))
logger.addAppender(a)
var argv: Array[String] = Array()
argv ++= Array("-S", pipeline)
argv ++= args
if (!args.contains("--log_to_file") && !args.contains("-log")) {
argv ++= List("--log_to_file", logFile.getAbsolutePath.replace("biopet", "queue"))
}
BiopetQCommandLine.main(argv)
}
}
\ No newline at end of file
......@@ -94,6 +94,8 @@ object BiopetQCommandLine extends GatkLogging {
if (CommandLineProgram.result != 0)
System.exit(CommandLineProgram.result)
}
val timestamp = System.currentTimeMillis
}
/**
......@@ -124,7 +126,7 @@ class BiopetQCommandLine extends CommandLineProgram with Logging {
org.apache.commons.io.IOUtils.copy(is, os)
os.close()
val s = if (t.getName.endsWith("/")) t.getName.substring(0, t.getName.length - 1) else t.getName
pipelineName = s.substring(0, s.lastIndexOf(".")) + "." + System.currentTimeMillis
pipelineName = s.substring(0, s.lastIndexOf(".")) + "." + BiopetQCommandLine.timestamp
}
// override createByType to pass the correct exceptions
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment