From d047c19ad1a6a5087425a0321340aa24adf7b82f Mon Sep 17 00:00:00 2001 From: Mark DePristo Date: Wed, 24 Aug 2011 13:52:05 -0400 Subject: [PATCH] Writes output to file --- .../org/broadinstitute/sting/queue/QCommandLine.scala | 4 +++- .../org/broadinstitute/sting/queue/util/JobLogging.scala | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/public/scala/src/org/broadinstitute/sting/queue/QCommandLine.scala b/public/scala/src/org/broadinstitute/sting/queue/QCommandLine.scala index becd1e1cf..c6d1f3883 100755 --- a/public/scala/src/org/broadinstitute/sting/queue/QCommandLine.scala +++ b/public/scala/src/org/broadinstitute/sting/queue/QCommandLine.scala @@ -115,7 +115,9 @@ class QCommandLine extends CommandLineProgram with Logging { // walk over each script, calling onExecutionDone for (script <- allQScripts) { script.onExecutionDone(qGraph.getFunctionsAndStatus(script.functions), qGraph.success) - JobLogging.printLogs(qGraph.getFunctionsAndStatus(script.functions)) + val reportFile = new File("joblogging.gatkreport.txt") + logger.info("Writing JobLogging GATKReport to file " + reportFile) + JobLogging.printLogs(qGraph.getFunctionsAndStatus(script.functions), reportFile) } if (!qGraph.success) { diff --git a/public/scala/src/org/broadinstitute/sting/queue/util/JobLogging.scala b/public/scala/src/org/broadinstitute/sting/queue/util/JobLogging.scala index d24ebe92b..3bb43508a 100644 --- a/public/scala/src/org/broadinstitute/sting/queue/util/JobLogging.scala +++ b/public/scala/src/org/broadinstitute/sting/queue/util/JobLogging.scala @@ -27,6 +27,7 @@ import org.broadinstitute.sting.queue.function.QFunction import org.broadinstitute.sting.gatk.report.{GATKReportTable, GATKReport} import org.broadinstitute.sting.utils.exceptions.UserException import org.broadinstitute.sting.queue.engine.JobRunInfo +import java.io.{FileOutputStream, PrintStream, File} /** * A mixin to add Job info to the class @@ -70,10 +71,10 @@ trait JobLogging extends QFunction { } object JobLogging { - def printLogs(jobs: Map[QFunction, JobRunInfo]) { + def printLogs(jobs: Map[QFunction, JobRunInfo], dest: File) { val jobLogs: List[JobLogging] = jobLoggingSublist(jobs.keys.toList) jobLogs.foreach((job: JobLogging) => job.addRunInfo(jobs.get(job).get)) - printJobLogging(jobLogs) + printJobLogging(jobLogs, new PrintStream(new FileOutputStream(dest))) } private def jobLoggingSublist(l: List[QFunction]): List[JobLogging] = { @@ -89,7 +90,7 @@ object JobLogging { * Prints the JobLogging logs to a GATKReport. First splits up the * logs by group, and for each group generates a GATKReportTable */ - private def printJobLogging(logs: List[JobLogging]) { + private def printJobLogging(logs: List[JobLogging], stream: PrintStream) { // create the report val report: GATKReport = new GATKReport @@ -108,7 +109,7 @@ object JobLogging { } } - report.print(System.out) + report.print(stream) } private def groupLogs(logs: List[JobLogging]): Map[String, List[JobLogging]] = {