mirror of
https://github.com/openstf/stf
synced 2025-10-04 02:09:32 +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()
|
var messageListener = wirerouter()
|
||||||
|
.on(wire.DeviceLogMessage, function(channel, message) {
|
||||||
|
socket.emit('device.log', message)
|
||||||
|
})
|
||||||
.on(wire.DevicePresentMessage, function(channel, message) {
|
.on(wire.DevicePresentMessage, function(channel, message) {
|
||||||
socket.emit('device.add', {
|
socket.emit('device.add', {
|
||||||
serial: message.serial
|
serial: message.serial
|
||||||
|
|
|
@ -10,6 +10,8 @@ module.exports = function(options) {
|
||||||
// We want to send logs before anything else start happening
|
// We want to send logs before anything else start happening
|
||||||
.dependency(require('./device/plugins/logsender'))
|
.dependency(require('./device/plugins/logsender'))
|
||||||
.define(function(options) {
|
.define(function(options) {
|
||||||
|
var log = logger.createLogger('device')
|
||||||
|
log.info('Preparing device')
|
||||||
return syrup()
|
return syrup()
|
||||||
.dependency(require('./device/plugins/solo'))
|
.dependency(require('./device/plugins/solo'))
|
||||||
.dependency(require('./device/plugins/heartbeat'))
|
.dependency(require('./device/plugins/heartbeat'))
|
||||||
|
@ -21,7 +23,6 @@ module.exports = function(options) {
|
||||||
.dependency(require('./device/plugins/touch'))
|
.dependency(require('./device/plugins/touch'))
|
||||||
.dependency(require('./device/plugins/owner'))
|
.dependency(require('./device/plugins/owner'))
|
||||||
.define(function(options, solo) {
|
.define(function(options, solo) {
|
||||||
var log = logger.createLogger('device')
|
|
||||||
if (process.send) {
|
if (process.send) {
|
||||||
// Only if we have a parent process
|
// Only if we have a parent process
|
||||||
process.send('ready')
|
process.send('ready')
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
var Promise = require('bluebird')
|
||||||
var syrup = require('syrup')
|
var syrup = require('syrup')
|
||||||
|
|
||||||
var logger = require('../../../util/logger')
|
var logger = require('../../../util/logger')
|
||||||
|
@ -6,11 +7,12 @@ var wireutil = require('../../../wire/util')
|
||||||
|
|
||||||
module.exports = syrup()
|
module.exports = syrup()
|
||||||
.dependency(require('../support/push'))
|
.dependency(require('../support/push'))
|
||||||
.define(function(options, push) {
|
.dependency(require('../support/quit'))
|
||||||
|
.define(function(options, push, quit) {
|
||||||
// Forward all logs
|
// Forward all logs
|
||||||
logger.on('entry', function(entry) {
|
logger.on('entry', function(entry) {
|
||||||
push.send([
|
push.send([
|
||||||
wireutil.log
|
wireutil.global
|
||||||
, wireutil.envelope(new wire.DeviceLogMessage(
|
, wireutil.envelope(new wire.DeviceLogMessage(
|
||||||
options.serial
|
options.serial
|
||||||
, entry.timestamp / 1000
|
, 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
|
return logger
|
||||||
})
|
})
|
||||||
|
|
|
@ -23,7 +23,7 @@ module.exports = function(options) {
|
||||||
})
|
})
|
||||||
|
|
||||||
// Establish always-on channels
|
// Establish always-on channels
|
||||||
;[wireutil.log].forEach(function(channel) {
|
;[wireutil.global].forEach(function(channel) {
|
||||||
log.info('Subscribing to permanent channel "%s"', channel)
|
log.info('Subscribing to permanent channel "%s"', channel)
|
||||||
sub.subscribe(channel)
|
sub.subscribe(channel)
|
||||||
})
|
})
|
||||||
|
|
|
@ -4,7 +4,6 @@ var wire = require('./')
|
||||||
|
|
||||||
var wireutil = {
|
var wireutil = {
|
||||||
global: '*ALL'
|
global: '*ALL'
|
||||||
, log: '*LOG'
|
|
||||||
, heartbeat: '*HB'
|
, heartbeat: '*HB'
|
||||||
, makePrivateChannel: function() {
|
, makePrivateChannel: function() {
|
||||||
return uuid.v4(null, new Buffer(16)).toString('base64')
|
return uuid.v4(null, new Buffer(16)).toString('base64')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue