Skip to content

Commit

Permalink
Added a global parameter for log-level. (#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
tfenne authored Oct 3, 2017
1 parent 2af6747 commit 0280b20
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/scala/com/fulcrumgenomics/cmdline/FgBioMain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ import java.text.DecimalFormat

import com.fulcrumgenomics.bam.api.{SamSource, SamWriter}
import com.fulcrumgenomics.cmdline.FgBioMain.FailureException
import com.fulcrumgenomics.commons.util.LazyLogging
import com.fulcrumgenomics.commons.util.{LazyLogging, LogLevel, Logger}
import com.fulcrumgenomics.sopt.{Sopt, arg}
import com.fulcrumgenomics.sopt.cmdline.{CommandLineParser, CommandLineProgramParserStrings}
import com.fulcrumgenomics.util.Io
import htsjdk.samtools.util.{BlockCompressedOutputStream, IOUtil, SnappyLoader}
import com.fulcrumgenomics.commons.CommonsDef._

import scala.reflect.runtime.universe.TypeTag
import scala.reflect.ClassTag

/**
* Main program for fgbio that loads everything up and runs the appropriate sub-command
*/
Expand All @@ -54,7 +57,8 @@ object FgBioMain {
class FgBioCommonArgs
( @arg(doc="Use asynchronous I/O where possible, e.g. for SAM and BAM files.") val asyncIo: Boolean = false,
@arg(doc="Default GZIP compression level, BAM compression level.") val compression: Int = 5,
@arg(doc="Directory to use for temporary files.") val tmpDir: DirPath = Paths.get(System.getProperty("java.io.tmpdir"))
@arg(doc="Directory to use for temporary files.") val tmpDir: DirPath = Paths.get(System.getProperty("java.io.tmpdir")),
@arg(doc="Minimum severity log-level to emit.") val logLevel: LogLevel = LogLevel.Info
) {

SamSource.DefaultUseAsyncIo = asyncIo
Expand All @@ -67,6 +71,8 @@ class FgBioCommonArgs

Io.tmpDir = tmpDir
System.setProperty("java.io.tmpdir", tmpDir.toAbsolutePath.toString)

Logger.level = this.logLevel
}

class FgBioMain extends LazyLogging {
Expand Down Expand Up @@ -112,6 +118,7 @@ class FgBioMain extends LazyLogging {
exit
}

/** The name of the toolkit, used in printing usage and status lines. */
protected def name: String = "fgbio"

/** Prints a line of useful information when a tool starts executing. */
Expand Down

0 comments on commit 0280b20

Please sign in to comment.