1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-05 19:42:01 +02:00

Starting to add Logcat.

This commit is contained in:
Gunther Brunner 2014-05-13 12:12:52 +09:00
parent 3b6da1542b
commit 9b304a939c
6 changed files with 75 additions and 8 deletions

View file

@ -0,0 +1,4 @@
module.exports = angular.module('stf.logcat', [
])
.factory('LogcatService', require('./logcat-service'))

View file

@ -0,0 +1,48 @@
var _ = require('lodash')
module.exports = function LogcatServiceFactory(socket) {
var LogcatService = {}
LogcatService.entries = []
LogcatService.logLevels = [
'UNKNOWN',
'DEFAULT',
'VERBOSE',
'DEBUG',
'INFO',
'WARN',
'ERROR',
'FATAL',
'SILENT'
]
var logLevelsLowerCase = _.map(LogcatService.logLevels, function (level) {
return level.toLowerCase()
})
var logLevelsCapitalized = _.map(logLevelsLowerCase, function (level) {
//return _.capitalize(level)
})
function enhanceEntry(data) {
var date = new Date(data.date)
// data.dateFormatted = _.pad(date.getHours(), 2, '0') + ':' +
// _.pad(date.getMinutes(), 2, '0') + ':' +
// _.pad(date.getSeconds(), 2, '0') + '.' +
// _.pad(date.getMilliseconds(), 3, '0')
return data
}
socket.on('logcat.entry', function (data) {
LogcatService.entries.push(enhanceEntry(data))
})
LogcatService.clear = function () {
LogcatService.entries = []
}
return LogcatService
}

View file

@ -0,0 +1,11 @@
describe('LogcatService', function() {
beforeEach(module('stf.logcat'));
it('should ...', inject(function(LogcatService) {
//expect(LogcatService.doSomething()).toEqual('something');
}));
})

View file

@ -1,7 +1,7 @@
require('./logs.less')
module.exports = angular.module('stf.logs', [
require('stf/logcat').name
])
.run(["$templateCache", function ($templateCache) {
$templateCache.put('control-panes/logs/logs.jade',

View file

@ -1,10 +1,8 @@
module.exports = function LogsCtrl($scope, socket) {
module.exports = function LogsCtrl($scope, LogcatService) {
var filters = []
socket.scoped($scope).on('logcat.entry', function (entry) {
console.log(entry)
})
$scope.logEntries = LogcatService.entries
$scope.$watch('started', function (newValue, oldValue) {
@ -19,6 +17,9 @@ module.exports = function LogsCtrl($scope, socket) {
}
}
})
});
$scope.clear = function () {
LogcatService.clear()
}
}

View file

@ -17,7 +17,10 @@
//table.table.table-condensed(ng-show='filtering.show')
//
table.table.table-condensed.logcat-filters-table(ng-show='true')
//tr
th(width='4%')//Line
th(width='10%') Device
@ -71,5 +74,5 @@
th(width='16%')
th(width='46%')
tbody#logcatBody
br
pre {{ logEntries | json }}
br