aboutsummaryrefslogtreecommitdiff
path: root/stage1/logger.scala
diff options
context:
space:
mode:
authorNikolay Tatarinov <5min4eq.unity@gmail.com>2016-06-24 02:48:45 +0300
committerJan Christopher Vogt <oss.nsp@cvogt.org>2016-06-23 19:48:45 -0400
commit2cbc42fd0809b60b1ee2116657d18b3f44f8aef1 (patch)
treee894a040137e591c4a7664b7353d709298a44f65 /stage1/logger.scala
parent75c32537cd8f29f9d12db37bf06ad942806f0239 (diff)
downloadcbt-2cbc42fd0809b60b1ee2116657d18b3f44f8aef1.tar.gz
cbt-2cbc42fd0809b60b1ee2116657d18b3f44f8aef1.tar.bz2
cbt-2cbc42fd0809b60b1ee2116657d18b3f44f8aef1.zip
Scalafmt plugin implementation (#156)
* scalariform: improve logging, declare tasks final * scalafmt plugin implementation * add scalafmt and scalariform plugins and examples to tests * fix logging guarded logging behaviour * add notes about formatting check to README * fix compilation error in examples
Diffstat (limited to 'stage1/logger.scala')
-rw-r--r--stage1/logger.scala38
1 files changed, 19 insertions, 19 deletions
diff --git a/stage1/logger.scala b/stage1/logger.scala
index 1e0a693..0b352a1 100644
--- a/stage1/logger.scala
+++ b/stage1/logger.scala
@@ -11,22 +11,26 @@ case class Logger(enabledLoggers: Set[String], start: Long) {
def this(enabledLoggers: Option[String], start: Long) = this( enabledLoggers.toVector.flatMap( _.split(",") ).toSet, start )
def log(name: String, msg: => String) = {
- val timeTaken = ((System.currentTimeMillis.toDouble - start) / 1000).toString
- System.err.println( s"[$timeTaken][$name] $msg" )
+ if(
+ (enabledLoggers contains name)
+ || (enabledLoggers contains "all")
+ ){
+ logUnguarded(name, msg)
+ }
}
def showInvocation(method: String, args: Any) = method ++ "( " ++ args.toString ++ " )"
- final def stage1(msg: => String) = logGuarded(names.stage1, msg)
- final def stage2(msg: => String) = logGuarded(names.stage2, msg)
- final def loop(msg: => String) = logGuarded(names.loop, msg)
- final def task(msg: => String) = logGuarded(names.task, msg)
- final def composition(msg: => String) = logGuarded(names.composition, msg)
- final def resolver(msg: => String) = logGuarded(names.resolver, msg)
- final def lib(msg: => String) = logGuarded(names.lib, msg)
- final def test(msg: => String) = logGuarded(names.test, msg)
- final def git(msg: => String) = logGuarded(names.git, msg)
- final def pom(msg: => String) = logGuarded(names.pom, msg)
+ final def stage1(msg: => String) = log(names.stage1, msg)
+ final def stage2(msg: => String) = log(names.stage2, msg)
+ final def loop(msg: => String) = log(names.loop, msg)
+ final def task(msg: => String) = log(names.task, msg)
+ final def composition(msg: => String) = log(names.composition, msg)
+ final def resolver(msg: => String) = log(names.resolver, msg)
+ final def lib(msg: => String) = log(names.lib, msg)
+ final def test(msg: => String) = log(names.test, msg)
+ final def git(msg: => String) = log(names.git, msg)
+ final def pom(msg: => String) = log(names.pom, msg)
private object names{
val stage1 = "stage1"
@@ -41,12 +45,8 @@ case class Logger(enabledLoggers: Set[String], start: Long) {
val git = "git"
}
- private def logGuarded(name: String, msg: => String) = {
- if(
- (enabledLoggers contains name)
- || (enabledLoggers contains "all")
- ){
- log(name, msg)
- }
+ private def logUnguarded(name: String, msg: => String) = {
+ val timeTaken = ((System.currentTimeMillis.toDouble - start) / 1000).toString
+ System.err.println( s"[$timeTaken][$name] $msg" )
}
}