mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Allow ParallelLogger to log from apply().
This commit is contained in:
parent
93d3d8ad53
commit
67dd7e54e9
1 changed files with 9 additions and 4 deletions
|
@ -32,15 +32,17 @@ class ParallelLogger @Inject constructor(val args: Args) : ILogger {
|
||||||
val newLine: Boolean)
|
val newLine: Boolean)
|
||||||
private val logLines = ConcurrentHashMap<CharSequence, ArrayList<LogLine>>()
|
private val logLines = ConcurrentHashMap<CharSequence, ArrayList<LogLine>>()
|
||||||
|
|
||||||
private val runningProjects = ConcurrentLinkedQueue<String>()
|
private val runningProjects = ConcurrentLinkedQueue<CharSequence>()
|
||||||
var startTime: Long? = null
|
var startTime: Long? = null
|
||||||
|
|
||||||
fun onProjectStarted(name: String) {
|
fun onProjectStarted(name: String) {
|
||||||
if (startTime == null) {
|
if (startTime == null) {
|
||||||
startTime = System.currentTimeMillis()
|
startTime = System.currentTimeMillis()
|
||||||
}
|
}
|
||||||
runningProjects.add(name)
|
if (! runningProjects.contains(name)) {
|
||||||
logLines[name] = arrayListOf()
|
runningProjects.add(name)
|
||||||
|
logLines[name] = arrayListOf()
|
||||||
|
}
|
||||||
if (currentName == null) {
|
if (currentName == null) {
|
||||||
currentName = name
|
currentName = name
|
||||||
}
|
}
|
||||||
|
@ -74,7 +76,7 @@ class ParallelLogger @Inject constructor(val args: Args) : ILogger {
|
||||||
}
|
}
|
||||||
|
|
||||||
val LOCK = Any()
|
val LOCK = Any()
|
||||||
var currentName: String? = null
|
var currentName: CharSequence? = null
|
||||||
set(newName) {
|
set(newName) {
|
||||||
field = newName
|
field = newName
|
||||||
}
|
}
|
||||||
|
@ -119,6 +121,9 @@ class ParallelLogger @Inject constructor(val args: Args) : ILogger {
|
||||||
if (args.sequential) {
|
if (args.sequential) {
|
||||||
kobaltLog(level, message, newLine)
|
kobaltLog(level, message, newLine)
|
||||||
} else {
|
} else {
|
||||||
|
if (! runningProjects.contains(tag)) {
|
||||||
|
runningProjects.add(tag)
|
||||||
|
}
|
||||||
addLogLine(tag, LogLine(tag, level, message, Type.LOG, newLine))
|
addLogLine(tag, LogLine(tag, level, message, Type.LOG, newLine))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue