Send logcat messages to group.

This commit is contained in:
Simo Kinnunen
2014-02-07 01:15:39 +09:00
parent a8fe5f6613
commit 6ae7c310e0

View File

@@ -321,6 +321,7 @@ module.exports = function(options) {
return adb.openLogcatAsync(options.serial)
.then(function(logcat) {
services.logcat = vitals.register('device:logcat', logcat)
resetLogcat()
})
})
.then(function() {
@@ -402,7 +403,7 @@ module.exports = function(options) {
})
})
.on(wire.LogcatApplyFiltersMessage, function(channel, message) {
services.logcat.resetFilters().excludeAll()
resetLogcat()
message.filters.forEach(function(filter) {
services.logcat.include(filter.tag, filter.priority)
})
@@ -474,6 +475,27 @@ module.exports = function(options) {
return !!owner
}
function resetLogcat() {
services.logcat
.resetFilters()
.excludeAll()
}
function logcatListener(entry) {
push.send([
owner.group
, wireutil.envelope(new wire.DeviceLogcatEntryMessage(
options.serial
, entry.date.getTime() / 1000
, entry.pid
, entry.tid
, entry.priority
, entry.tag
, entry.message
))
])
}
function joinGroup(newOwner, timeout) {
log.info('Now owned by "%s"', newOwner.email)
log.info('Subscribing to group channel "%s"', newOwner.group)
@@ -486,6 +508,7 @@ module.exports = function(options) {
, newOwner
))
])
services.logcat.on('entry', logcatListener)
owner = newOwner
}
@@ -501,6 +524,7 @@ module.exports = function(options) {
, owner
))
])
services.logcat.removeListener('entry', logcatListener)
owner = null
}