Skip to content

Commit 046d2ed

Browse files
author
Johann Egger
committed
Adds debug property
you can activate debug with -Ddebug="true" but be aware that the debug output will interfere with the parsing logic
1 parent f5fb8f0 commit 046d2ed

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/main/scala/codacy/dockerApi/DockerEngine.scala

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,22 @@ abstract class DockerEngine(Tool: Tool) {
1515
def initTimeout(duration: FiniteDuration) = {
1616
implicit val ct: ExecutionContext = sys.dispatcher
1717
sys.scheduler.scheduleOnce(duration){
18-
Runtime.getRuntime().halt(1)
18+
Runtime.getRuntime().halt(2)
1919
}
2020
}
2121

2222
lazy val timeout = Option(System.getProperty("timeout")).flatMap{ case rawDuration =>
2323
Try(Duration(rawDuration)).toOption.collect{ case d:FiniteDuration => d }
2424
}.getOrElse(30.minutes)
2525

26+
lazy val isDebug = Option(System.getProperty("debug")).flatMap{ case rawDuration =>
27+
Try(rawDuration.toBoolean).toOption
28+
}.getOrElse(false)
29+
30+
def log(message:String):Unit = if(isDebug){
31+
Console.err.print(s"[DockerEngine] $message")
32+
}
33+
2634
def main(args: Array[String]): Unit = {
2735
initTimeout(timeout)
2836

@@ -37,6 +45,7 @@ abstract class DockerEngine(Tool: Tool) {
3745
sourcePath.resolve(path.value)
3846
}))
3947

48+
log("tool started")
4049
Tool(
4150
path = sourcePath,
4251
conf = maybePatterns,
@@ -45,6 +54,7 @@ abstract class DockerEngine(Tool: Tool) {
4554
}
4655
} match {
4756
case Success(results) =>
57+
log("receiving results")
4858
results.foreach {
4959
case issue: Issue =>
5060
val relativeIssue = issue.copy(filename = SourcePath(relativize(issue.filename.value)))
@@ -53,7 +63,7 @@ abstract class DockerEngine(Tool: Tool) {
5363
val relativeIssue = error.copy(filename = SourcePath(relativize(error.filename.value)))
5464
logResult(relativeIssue)
5565
}
56-
66+
log("tool finished")
5767
case Failure(error) =>
5868
error.printStackTrace(Console.err)
5969
System.exit(1)

0 commit comments

Comments
 (0)