mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-25 07:57:12 -07:00
Introducing --logTags.
This commit is contained in:
parent
4e3d727da6
commit
09ae7c00aa
4 changed files with 17 additions and 11 deletions
|
@ -46,6 +46,10 @@ class Args {
|
|||
"(${Constants.LOG_DEFAULT_LEVEL}-${Constants.LOG_MAX_LEVEL})")
|
||||
var log: Int = Constants.LOG_DEFAULT_LEVEL
|
||||
|
||||
@Parameter(names = arrayOf("--logTags"),
|
||||
description = "Comma-separated list of tags to enable logging for")
|
||||
var logTags: String = ""
|
||||
|
||||
@Parameter(names = arrayOf("--forceIncremental"),
|
||||
description = "Force the build to be incremental even if the build file was modified")
|
||||
var forceIncremental: Boolean = false
|
||||
|
|
|
@ -15,7 +15,7 @@ abstract class BaseProjectRunner {
|
|||
: TaskManager.RunTargetResult
|
||||
|
||||
companion object {
|
||||
val LOG_LEVEL = TaskManager.LOG_LEVEL
|
||||
val TAG = "graph"
|
||||
|
||||
fun runBuildListenersForProject(project: Project, context: KobaltContext, start: Boolean,
|
||||
status: ProjectBuildStatus = ProjectBuildStatus.SUCCESS) {
|
||||
|
@ -86,7 +86,7 @@ abstract class BaseProjectRunner {
|
|||
val froms = nodeMap[from]
|
||||
froms.forEach { f: T ->
|
||||
nodeMap[to].forEach { t: T ->
|
||||
kobaltLog(LOG_LEVEL, " Adding edge ($text) $f -> $t")
|
||||
kobaltLog(TAG, " Adding edge ($text) $f -> $t")
|
||||
result.addEdge(f, t)
|
||||
newToProcess.add(t)
|
||||
}
|
||||
|
@ -97,19 +97,19 @@ abstract class BaseProjectRunner {
|
|||
* Whenever a task is added to the graph, we also add its alwaysRunAfter tasks.
|
||||
*/
|
||||
fun processAlways(always: Multimap<String, String>, node: T) {
|
||||
kobaltLog(LOG_LEVEL, " Processing always for $node")
|
||||
kobaltLog(TAG, " Processing always for $node")
|
||||
always[toName(node)]?.let { to: Collection<String> ->
|
||||
to.forEach { t ->
|
||||
nodeMap[t].forEach { from ->
|
||||
kobaltLog(LOG_LEVEL, " Adding always edge $from -> $node")
|
||||
kobaltLog(TAG, " Adding always edge $from -> $node")
|
||||
result.addEdge(from, node)
|
||||
}
|
||||
}
|
||||
kobaltLog(LOG_LEVEL, " ... done processing always for $node")
|
||||
kobaltLog(TAG, " ... done processing always for $node")
|
||||
}
|
||||
}
|
||||
|
||||
kobaltLog(LOG_LEVEL, " Current batch to process: $toProcess")
|
||||
kobaltLog(TAG, " Current batch to process: $toProcess")
|
||||
|
||||
//
|
||||
// Move dependsOn + reverseDependsOn in one multimap called allDepends
|
||||
|
@ -131,7 +131,7 @@ abstract class BaseProjectRunner {
|
|||
//
|
||||
toProcess.forEach { taskInfo ->
|
||||
val taskName = taskInfo.taskName
|
||||
kobaltLog(LOG_LEVEL, " ***** Current node: $taskName")
|
||||
kobaltLog(TAG, " ***** Current node: $taskName")
|
||||
nodeMap[taskName].forEach {
|
||||
result.addNode(it)
|
||||
processAlways(always, it)
|
||||
|
|
|
@ -24,10 +24,6 @@ class TaskManager @Inject constructor(val args: Args,
|
|||
private val runAfter = TreeMultimap.create<String, String>()
|
||||
private val alwaysRunAfter = TreeMultimap.create<String, String>()
|
||||
|
||||
companion object {
|
||||
val LOG_LEVEL = 3
|
||||
}
|
||||
|
||||
/**
|
||||
* Dependency: task2 depends on task 1.
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.beust.kobalt.misc
|
||||
|
||||
import com.beust.kobalt.Args
|
||||
import com.beust.kobalt.AsciiArt
|
||||
import com.beust.kobalt.KobaltException
|
||||
import com.beust.kobalt.api.Kobalt
|
||||
|
@ -15,6 +16,11 @@ fun Any.log(level: Int, text: CharSequence, newLine : Boolean = true) {
|
|||
fun Any.kobaltLog(level: Int, text: CharSequence, newLine : Boolean = true) = log(level, text, newLine)
|
||||
fun Any.kobaltWarn(text: CharSequence) = warn(text)
|
||||
fun Any.kobaltError(text: CharSequence) = error(text)
|
||||
fun Any.kobaltLog(tag: String, text: CharSequence, newLine : Boolean = true) {
|
||||
if (Kobalt.INJECTOR.getInstance(Args::class.java).logTags.split(',').contains(tag)) {
|
||||
log(1, text, newLine)
|
||||
}
|
||||
}
|
||||
|
||||
fun Any.logWrap(level: Int, text1: CharSequence, text2: CharSequence, function: () -> Unit) {
|
||||
if (level <= KobaltLogger.LOG_LEVEL) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue