From 1cd848cd9b4c25dffd352c1e51cf852eb1281f01 Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Thu, 2 Dec 2010 19:14:30 -0500 Subject: [PATCH] introduce sbt.log.format for explicit formatting control implements issue #134 if true, formatting enabled if false, formatting disabled if unset, formatting configured as before sbt.log.noformat is no longer recommended, but is supported: a. setting it to 'true' explicitly disables formatting b. if 'false' or unspecified, autodetection is used c. sbt.log.format takes precedence if defined --- util/log/ConsoleLogger.scala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/util/log/ConsoleLogger.scala b/util/log/ConsoleLogger.scala index 59bc680c3..0f9e78b22 100644 --- a/util/log/ConsoleLogger.scala +++ b/util/log/ConsoleLogger.scala @@ -21,9 +21,13 @@ object ConsoleLogger def println() = out.println() } - private val formatEnabled = ansiSupported && !formatExplicitlyDisabled + val formatEnabled = + { + import java.lang.Boolean.{getBoolean, parseBoolean} + val value = System.getProperty("sbt.log.format") + if(value eq null) (ansiSupported && !getBoolean("sbt.log.noformat")) else parseBoolean(value) + } - private[this] def formatExplicitlyDisabled = java.lang.Boolean.getBoolean("sbt.log.noformat") private[this] def ansiSupported = try { jline.Terminal.getTerminal.isANSISupported } catch { case e: Exception => !isWindows }