Commit 5e118891 authored by Ian Fischer's avatar Ian Fischer

Add logs command and android implementation.

parent 61bfe5ce
...@@ -13,6 +13,7 @@ import 'package:sky_tools/src/build.dart'; ...@@ -13,6 +13,7 @@ import 'package:sky_tools/src/build.dart';
import 'package:sky_tools/src/cache.dart'; import 'package:sky_tools/src/cache.dart';
import 'package:sky_tools/src/init.dart'; import 'package:sky_tools/src/init.dart';
import 'package:sky_tools/src/install.dart'; import 'package:sky_tools/src/install.dart';
import 'package:sky_tools/src/logs.dart';
import 'package:sky_tools/src/run_mojo.dart'; import 'package:sky_tools/src/run_mojo.dart';
import 'package:sky_tools/src/start.dart'; import 'package:sky_tools/src/start.dart';
import 'package:sky_tools/src/stop.dart'; import 'package:sky_tools/src/stop.dart';
...@@ -148,6 +149,7 @@ void main(List<String> args) { ...@@ -148,6 +149,7 @@ void main(List<String> args) {
..addCommand(new CacheCommand()) ..addCommand(new CacheCommand())
..addCommand(new InitCommand()) ..addCommand(new InitCommand())
..addCommand(new InstallCommand()) ..addCommand(new InstallCommand())
..addCommand(new LogsCommand())
..addCommand(new RunMojoCommand()) ..addCommand(new RunMojoCommand())
..addCommand(new StartCommand()) ..addCommand(new StartCommand())
..addCommand(new StopCommand()) ..addCommand(new StopCommand())
......
...@@ -317,6 +317,26 @@ class AndroidDevice extends _Device { ...@@ -317,6 +317,26 @@ class AndroidDevice extends _Device {
return true; return true;
} }
void clearLogs() {
runSync([adbPath, 'logcat', '-c']);
}
Future<int> logs({bool clear: false}) {
if (clear) {
clearLogs();
}
return runCommandAndStreamOutput([
adbPath,
'logcat',
'-v',
'tag', // Only log the tag and the message
'-s',
'sky',
'chromium',
]);
}
@override @override
bool isConnected() => _hasValidAndroid; bool isConnected() => _hasValidAndroid;
} }
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library sky_tools.logs;
import 'dart:async';
import 'package:args/command_runner.dart';
import 'package:logging/logging.dart';
import 'package:sky_tools/src/device.dart';
final Logger _logging = new Logger('sky_tools.logs');
class LogsCommand extends Command {
final name = 'logs';
final description = 'Show logs for running Sky apps.';
AndroidDevice android = null;
LogsCommand([this.android]) {
argParser.addFlag('clear',
negatable: false,
help: 'Clear log history before reading from logs (Android only).');
if (android == null) {
android = new AndroidDevice();
}
}
@override
Future<int> run() async {
Future<int> androidLogProcess = null;
if (android.isConnected()) {
androidLogProcess = android.logs(clear: argResults['clear']);
}
if (androidLogProcess != null) {
await androidLogProcess;
}
return 0;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment