diff options
author | Jan Christopher Vogt <oss.nsp@cvogt.org> | 2016-03-06 14:00:58 -0500 |
---|---|---|
committer | Jan Christopher Vogt <oss.nsp@cvogt.org> | 2016-03-06 14:00:58 -0500 |
commit | bd9b6555da1bcfb59a2a08ac7b20b6f5621b5e3d (patch) | |
tree | cec409518b4b129f526f41bddf62454a5f37e203 /stage1 | |
parent | 510f2a18d1f6f66ef066095b15d98b81c5a3a130 (diff) | |
parent | 8ae55d98a7796ada169955c3d96423550a431d99 (diff) | |
download | cbt-bd9b6555da1bcfb59a2a08ac7b20b6f5621b5e3d.tar.gz cbt-bd9b6555da1bcfb59a2a08ac7b20b6f5621b5e3d.tar.bz2 cbt-bd9b6555da1bcfb59a2a08ac7b20b6f5621b5e3d.zip |
Merge pull request #45 from farmdawgnation/farmdawg/stage2tweaks
Stage 2 / Logger cleanups.
Diffstat (limited to 'stage1')
-rw-r--r-- | stage1/Stage1.scala | 2 | ||||
-rw-r--r-- | stage1/logger.scala | 23 |
2 files changed, 17 insertions, 8 deletions
diff --git a/stage1/Stage1.scala b/stage1/Stage1.scala index 6c05f00..5391e2d 100644 --- a/stage1/Stage1.scala +++ b/stage1/Stage1.scala @@ -14,7 +14,7 @@ object CheckAlive{ } } -class Init(args: Array[String]) { +private[cbt] class Init(args: Array[String]) { /** * Raw parameters including their `-D` flag. **/ diff --git a/stage1/logger.scala b/stage1/logger.scala index 16bd940..eaf64db 100644 --- a/stage1/logger.scala +++ b/stage1/logger.scala @@ -1,15 +1,24 @@ package cbt + import java.time._ -// We can replace this with something more sophisticated eventually -case class Logger(enabledLoggers: Set[String]){ - val start = LocalTime.now() - //System.err.println("Created Logger("+enabledLoggers+")") + +/** + * This represents a logger with namespaces that can be enabled or disabled as needed. The + * namespaces are defined using {{enabledLoggers}}. Possible values are defined in the subobject + * "names". + * + * We can replace this with something more sophisticated eventually. + */ +case class Logger(enabledLoggers: Set[String]) { def this(enabledLoggers: Option[String]) = this( enabledLoggers.toVector.flatMap( _.split(",") ).toSet ) + + val start = LocalTime.now() + def log(name: String, msg: => String) = { val timeTaken = (Duration.between(start, LocalTime.now()).toMillis.toDouble / 1000).toString - System.err.println( s"[${" "*(6-timeTaken.size)}$timeTaken]["+name+"] " + msg ) + System.err.println( s"[${" "*(6-timeTaken.size)}$timeTaken][$name] $msg" ) } - + def showInvocation(method: String, args: Any) = method + "( " + args + " )" final def stage1(msg: => String) = logGuarded(names.stage1, msg) @@ -38,4 +47,4 @@ case class Logger(enabledLoggers: Set[String]){ log(name, msg) } } -}
\ No newline at end of file +} |