mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Log clean up.
This commit is contained in:
parent
a55256133e
commit
a15cd1769e
5 changed files with 22 additions and 20 deletions
|
@ -75,20 +75,21 @@ class AsciiArt {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun fill(n: Int) = StringBuffer().apply { repeat(n, { append(" ")})}.toString()
|
|
||||||
|
|
||||||
val defaultLog : (s: String) -> Unit = { log(1, " $it") }
|
val defaultLog : (s: String) -> Unit = { log(1, " $it") }
|
||||||
|
|
||||||
fun logBox(strings: List<String>, bl: String = bottomLeft, br: String = bottomRight,
|
fun logBox(strings: List<String>, bl: String = bottomLeft, br: String = bottomRight,
|
||||||
print: (String) -> Unit = defaultLog) {
|
indent: Int = 0): String {
|
||||||
box(strings, bl, br).forEach {
|
return buildString {
|
||||||
print(it)
|
box(strings, bl, br).forEach {
|
||||||
|
append(fill(indent)).append(it).append("\n")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun logBox(s: String, bl: String = bottomLeft, br: String = bottomRight, print: (String) -> Unit = defaultLog) {
|
fun logBox(s: String, bl: String = bottomLeft, br: String = bottomRight, indent: Int = 0)
|
||||||
logBox(listOf(s), bl, br, print)
|
= logBox(listOf(s), bl, br, indent)
|
||||||
}
|
|
||||||
|
fun fill(n: Int) = buildString { repeat(n, { append(" ")})}.toString()
|
||||||
|
|
||||||
fun center(s: String, width: Int) : String {
|
fun center(s: String, width: Int) : String {
|
||||||
val diff = width - s.length
|
val diff = width - s.length
|
||||||
|
@ -139,23 +140,24 @@ class AsciiTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
val vb = AsciiArt.verticalBar
|
val vb = AsciiArt.verticalBar
|
||||||
|
|
||||||
fun build() : String {
|
fun build() : String {
|
||||||
val formattedHeaders =
|
val formattedHeaders =
|
||||||
headers.mapIndexed { index, s ->
|
headers.mapIndexed { index, s ->
|
||||||
val s2 = col(widths[index], s)
|
val s2 = col(widths[index], s)
|
||||||
s2
|
s2
|
||||||
}.joinToString(vb)
|
}.joinToString(vb)
|
||||||
val result = buildString {
|
val result = StringBuffer().apply {
|
||||||
append(AsciiArt.logBox(formattedHeaders, AsciiArt.bottomLeft2, AsciiArt.bottomRight2))
|
append(AsciiArt.logBox(formattedHeaders, AsciiArt.bottomLeft2, AsciiArt.bottomRight2))
|
||||||
}
|
}
|
||||||
var lineLength = 0
|
var lineLength = 0
|
||||||
rows.forEachIndexed { index, row ->
|
rows.forEachIndexed { index, row ->
|
||||||
val formattedRow = row.mapIndexed { i, s -> col(widths[i], s) }.joinToString(vb)
|
val formattedRow = row.mapIndexed { i, s -> col(widths[i], s) }.joinToString(vb)
|
||||||
val line = vb + " " + formattedRow + " " + vb
|
val line = vb + " " + formattedRow + " " + vb
|
||||||
AsciiArt.defaultLog(line)
|
result.append(line).append("\n")
|
||||||
lineLength = line.length
|
lineLength = line.length
|
||||||
}
|
}
|
||||||
AsciiArt.defaultLog(AsciiArt.lowerBox(lineLength - 4))
|
result.append(AsciiArt.lowerBox(lineLength - 4))
|
||||||
return result.toString()
|
return result.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ class ResolveDependency @Inject constructor(
|
||||||
val seen = hashSetOf(dep.id)
|
val seen = hashSetOf(dep.id)
|
||||||
root.addChildren(findChildren(root, seen))
|
root.addChildren(findChildren(root, seen))
|
||||||
|
|
||||||
AsciiArt.logBox(listOf(dep.id, url, dep.jarFile.get()).map { " $it" })
|
log(1, AsciiArt.logBox(listOf(dep.id, url, dep.jarFile.get()).map { " $it" }))
|
||||||
|
|
||||||
display(root.children)
|
display(root.children)
|
||||||
println("")
|
println("")
|
||||||
|
|
|
@ -80,15 +80,17 @@ class BuildListeners : IBuildListener, IBuildReportContributor {
|
||||||
// if (timings.size > 1 && hasFailures) {
|
// if (timings.size > 1 && hasFailures) {
|
||||||
val line = listOf(col1("Project"), col2("Build status"), col3("Time"))
|
val line = listOf(col1("Project"), col2("Build status"), col3("Time"))
|
||||||
.joinToString(AsciiArt.verticalBar)
|
.joinToString(AsciiArt.verticalBar)
|
||||||
AsciiArt.logBox(listOf(line), AsciiArt.bottomLeft2, AsciiArt.bottomRight2)
|
val table = StringBuffer()
|
||||||
|
table.append(AsciiArt.logBox(listOf(line), AsciiArt.bottomLeft2, AsciiArt.bottomRight2, indent = 10))
|
||||||
projectStatuses.forEach { pair ->
|
projectStatuses.forEach { pair ->
|
||||||
val projectName = pair.first.name
|
val projectName = pair.first.name
|
||||||
val cl = listOf(col1(projectName), col2(pair.second.toString()),
|
val cl = listOf(col1(projectName), col2(pair.second.toString()),
|
||||||
col3(formatMillisLeft(projectInfos[projectName]!!.durationMillis, 8)))
|
col3(formatMillisLeft(projectInfos[projectName]!!.durationMillis, 8)))
|
||||||
.joinToString(AsciiArt.verticalBar)
|
.joinToString(AsciiArt.verticalBar)
|
||||||
log(1, " " + AsciiArt.verticalBar + " " + cl + " " + AsciiArt.verticalBar)
|
table.append(" " + AsciiArt.verticalBar + " " + cl + " " + AsciiArt.verticalBar + "\n")
|
||||||
}
|
}
|
||||||
log(1, " " + AsciiArt.lowerBox(line.length))
|
table.append(" " + AsciiArt.lowerBox(line.length))
|
||||||
|
log(1, table.toString())
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -276,10 +276,8 @@ class DynamicGraphExecutor<T>(val graph : DynamicGraph<T>, val factory: IThreadW
|
||||||
table.width(20)
|
table.width(20)
|
||||||
}
|
}
|
||||||
table.header("Time (sec)")
|
table.header("Time (sec)")
|
||||||
val header = StringBuffer().apply {
|
threadIds.keys.forEach {
|
||||||
threadIds.keys.forEach {
|
table.header("Thread " + it.toString())
|
||||||
table.header("Thread " + it.toString())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toSeconds(millis: Long) = (millis / 1000).toInt().toString()
|
fun toSeconds(millis: Long) = (millis / 1000).toInt().toString()
|
||||||
|
|
|
@ -34,7 +34,7 @@ class SequentialProjectRunner(val tasksByNames: (Project) -> ListMultimap<String
|
||||||
|
|
||||||
val context = Kobalt.context!!
|
val context = Kobalt.context!!
|
||||||
projects.forEach { project ->
|
projects.forEach { project ->
|
||||||
AsciiArt.logBox("Building ${project.name}")
|
log(1, AsciiArt.logBox("Building ${project.name}", indent = 5))
|
||||||
|
|
||||||
// Does the current project depend on any failed projects?
|
// Does the current project depend on any failed projects?
|
||||||
val fp = project.dependsOn.filter { failedProjects.contains(it.name) }.map(Project::name)
|
val fp = project.dependsOn.filter { failedProjects.contains(it.name) }.map(Project::name)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue