mirror of
https://github.com/openstf/stf
synced 2025-10-04 18:29:17 +02:00
Send device logs to app.
This commit is contained in:
parent
f93e5423a8
commit
ccef3624df
5 changed files with 15 additions and 5 deletions
|
@ -245,6 +245,9 @@ module.exports = function(options) {
|
|||
}
|
||||
|
||||
var messageListener = wirerouter()
|
||||
.on(wire.DeviceLogMessage, function(channel, message) {
|
||||
socket.emit('device.log', message)
|
||||
})
|
||||
.on(wire.DevicePresentMessage, function(channel, message) {
|
||||
socket.emit('device.add', {
|
||||
serial: message.serial
|
||||
|
|
|
@ -10,6 +10,8 @@ module.exports = function(options) {
|
|||
// We want to send logs before anything else start happening
|
||||
.dependency(require('./device/plugins/logsender'))
|
||||
.define(function(options) {
|
||||
var log = logger.createLogger('device')
|
||||
log.info('Preparing device')
|
||||
return syrup()
|
||||
.dependency(require('./device/plugins/solo'))
|
||||
.dependency(require('./device/plugins/heartbeat'))
|
||||
|
@ -21,7 +23,6 @@ module.exports = function(options) {
|
|||
.dependency(require('./device/plugins/touch'))
|
||||
.dependency(require('./device/plugins/owner'))
|
||||
.define(function(options, solo) {
|
||||
var log = logger.createLogger('device')
|
||||
if (process.send) {
|
||||
// Only if we have a parent process
|
||||
process.send('ready')
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
var Promise = require('bluebird')
|
||||
var syrup = require('syrup')
|
||||
|
||||
var logger = require('../../../util/logger')
|
||||
|
@ -6,11 +7,12 @@ var wireutil = require('../../../wire/util')
|
|||
|
||||
module.exports = syrup()
|
||||
.dependency(require('../support/push'))
|
||||
.define(function(options, push) {
|
||||
.dependency(require('../support/quit'))
|
||||
.define(function(options, push, quit) {
|
||||
// Forward all logs
|
||||
logger.on('entry', function(entry) {
|
||||
push.send([
|
||||
wireutil.log
|
||||
wireutil.global
|
||||
, wireutil.envelope(new wire.DeviceLogMessage(
|
||||
options.serial
|
||||
, entry.timestamp / 1000
|
||||
|
@ -23,5 +25,10 @@ module.exports = syrup()
|
|||
])
|
||||
})
|
||||
|
||||
quit.observe(function() {
|
||||
// Let's give it some time to flush logs before dying
|
||||
return Promise.delay(500)
|
||||
})
|
||||
|
||||
return logger
|
||||
})
|
||||
|
|
|
@ -23,7 +23,7 @@ module.exports = function(options) {
|
|||
})
|
||||
|
||||
// Establish always-on channels
|
||||
;[wireutil.log].forEach(function(channel) {
|
||||
;[wireutil.global].forEach(function(channel) {
|
||||
log.info('Subscribing to permanent channel "%s"', channel)
|
||||
sub.subscribe(channel)
|
||||
})
|
||||
|
|
|
@ -4,7 +4,6 @@ var wire = require('./')
|
|||
|
||||
var wireutil = {
|
||||
global: '*ALL'
|
||||
, log: '*LOG'
|
||||
, heartbeat: '*HB'
|
||||
, makePrivateChannel: function() {
|
||||
return uuid.v4(null, new Buffer(16)).toString('base64')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue