Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
896246ad
Commit
896246ad
authored
Feb 22, 2016
by
Devon Carew
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2079 from devoncarew/more_specific_logging
log for specific adb devices
parents
2b70fda1
488e5dcd
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
20 deletions
+26
-20
android_device.dart
packages/flutter_tools/lib/src/android/android_device.dart
+17
-11
logs.dart
packages/flutter_tools/lib/src/commands/logs.dart
+3
-3
device.dart
packages/flutter_tools/lib/src/device.dart
+1
-1
devices.dart
packages/flutter_tools/lib/src/ios/devices.dart
+2
-2
simulators.dart
packages/flutter_tools/lib/src/ios/simulators.dart
+3
-3
No files found.
packages/flutter_tools/lib/src/android/android_device.dart
View file @
896246ad
...
...
@@ -307,7 +307,7 @@ class AndroidDevice extends Device {
TargetPlatform
get
platform
=>
TargetPlatform
.
android
;
void
clearLogs
()
{
runSync
(
adbCommandForDevice
(<
String
>[
'logcat'
,
'-c'
]));
runSync
(
adbCommandForDevice
(<
String
>[
'
-s'
,
id
,
'
logcat'
,
'-c'
]));
}
DeviceLogReader
createLogReader
()
=>
new
_AdbLogReader
(
this
);
...
...
@@ -322,10 +322,12 @@ class AndroidDevice extends Device {
]));
}
// Return the most recent timestamp in the Android log.
The format can be
// Return the most recent timestamp in the Android log. The format can be
// passed to logcat's -T option.
String
lastLogcatTimestamp
()
{
String
output
=
runCheckedSync
(
adbCommandForDevice
(<
String
>[
'logcat'
,
'-v'
,
'time'
,
'-t'
,
'1'
]));
String
output
=
runCheckedSync
(
adbCommandForDevice
(<
String
>[
'-s'
,
id
,
'logcat'
,
'-v'
,
'time'
,
'-t'
,
'1'
]));
RegExp
timeRegExp
=
new
RegExp
(
r'^\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3}'
,
multiLine:
true
);
Match
timeMatch
=
timeRegExp
.
firstMatch
(
output
);
...
...
@@ -350,7 +352,9 @@ class AndroidDevice extends Device {
String
tracePath
=
null
;
bool
isComplete
=
false
;
while
(!
isComplete
)
{
String
logs
=
runCheckedSync
(
adbCommandForDevice
(<
String
>[
'logcat'
,
'-d'
,
'-T'
,
beforeStop
]));
String
logs
=
runCheckedSync
(
adbCommandForDevice
(<
String
>[
'-s'
,
id
,
'logcat'
,
'-d'
,
'-T'
,
beforeStop
]));
Match
fileMatch
=
traceRegExp
.
firstMatch
(
logs
);
if
(
fileMatch
!=
null
&&
fileMatch
[
1
]
!=
null
)
{
tracePath
=
fileMatch
[
1
];
...
...
@@ -484,16 +488,15 @@ List<AndroidDevice> getAdbDevices() {
return
devices
;
}
/// A log reader that logs from `adb logcat`. This will have the same output as
/// another copy of [_AdbLogReader], and the two instances will be equivalent.
/// A log reader that logs from `adb logcat`.
class
_AdbLogReader
extends
DeviceLogReader
{
_AdbLogReader
(
this
.
device
);
final
AndroidDevice
device
;
String
get
name
=>
'Android'
;
String
get
name
=>
device
.
name
;
Future
<
int
>
logs
({
bool
clear:
false
})
async
{
Future
<
int
>
logs
({
bool
clear:
false
,
bool
showPrefix:
false
})
async
{
if
(!
device
.
isConnected
())
return
2
;
...
...
@@ -501,6 +504,8 @@ class _AdbLogReader extends DeviceLogReader {
device
.
clearLogs
();
return
await
runCommandAndStreamOutput
(
device
.
adbCommandForDevice
(<
String
>[
'-s'
,
device
.
id
,
'logcat'
,
'-v'
,
'tag'
,
// Only log the tag and the message
...
...
@@ -509,15 +514,16 @@ class _AdbLogReader extends DeviceLogReader {
'ActivityManager:W'
,
'System.err:W'
,
'*:F'
,
]),
prefix:
'[Android]
'
);
]),
prefix:
showPrefix
?
'[
$name
] '
:
'
'
);
}
// Intentionally constant; overridden because we've overridden the `operator ==` method below.
int
get
hashCode
=>
name
.
hashCode
;
bool
operator
==(
dynamic
other
)
{
if
(
identical
(
this
,
other
))
return
true
;
return
other
is
_AdbLogReader
;
if
(
other
is
!
_AdbLogReader
)
return
false
;
return
other
.
device
.
id
==
device
.
id
;
}
}
packages/flutter_tools/lib/src/commands/logs.dart
View file @
896246ad
...
...
@@ -35,15 +35,15 @@ class LogsCommand extends FlutterCommand {
bool
clear
=
argResults
[
'clear'
];
Set
<
DeviceLogReader
>
readers
=
new
Se
t
<
DeviceLogReader
>();
List
<
DeviceLogReader
>
readers
=
new
Lis
t
<
DeviceLogReader
>();
for
(
Device
device
in
devices
)
{
readers
.
add
(
device
.
createLogReader
());
}
printStatus
(
'Showing
logs for
${readers.join(', ')}
:'
);
printStatus
(
'Showing
${readers.join(', ')}
logs
:'
);
List
<
int
>
results
=
await
Future
.
wait
(
readers
.
map
((
DeviceLogReader
reader
)
async
{
int
result
=
await
reader
.
logs
(
clear:
clear
);
int
result
=
await
reader
.
logs
(
clear:
clear
,
showPrefix:
devices
.
length
>
1
);
if
(
result
!=
0
)
printError
(
'Error listening to
$reader
logs.'
);
return
result
;
...
...
packages/flutter_tools/lib/src/device.dart
View file @
896246ad
...
...
@@ -189,7 +189,7 @@ abstract class Device {
abstract
class
DeviceLogReader
{
String
get
name
;
Future
<
int
>
logs
({
bool
clear:
false
});
Future
<
int
>
logs
({
bool
clear:
false
,
bool
showPrefix:
false
});
int
get
hashCode
;
bool
operator
==(
dynamic
other
);
...
...
packages/flutter_tools/lib/src/ios/devices.dart
View file @
896246ad
...
...
@@ -232,13 +232,13 @@ class _IOSDeviceLogReader extends DeviceLogReader {
String
get
name
=>
device
.
name
;
// TODO(devoncarew): Support [clear].
Future
<
int
>
logs
({
bool
clear:
false
})
async
{
Future
<
int
>
logs
({
bool
clear:
false
,
bool
showPrefix:
false
})
async
{
if
(!
device
.
isConnected
())
return
2
;
return
await
runCommandAndStreamOutput
(
<
String
>[
device
.
loggerPath
],
prefix:
'[
$name
]
'
,
prefix:
showPrefix
?
'[
$name
] '
:
'
'
,
filter:
new
RegExp
(
r'Runner'
)
);
}
...
...
packages/flutter_tools/lib/src/ios/simulators.dart
View file @
896246ad
...
...
@@ -410,7 +410,7 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
String
get
name
=>
device
.
name
;
Future
<
int
>
logs
({
bool
clear:
false
})
async
{
Future
<
int
>
logs
({
bool
clear:
false
,
bool
showPrefix:
false
})
async
{
if
(!
device
.
isConnected
())
return
2
;
...
...
@@ -432,7 +432,7 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
Future
<
int
>
result
=
runCommandAndStreamOutput
(
<
String
>[
'tail'
,
'-n'
,
'+0'
,
'-F'
,
device
.
logFilePath
],
prefix:
'[
$name
]
'
,
prefix:
showPrefix
?
'[
$name
] '
:
'
'
,
mapFunction:
(
String
string
)
{
Match
match
=
mapRegex
.
matchAsPrefix
(
string
);
if
(
match
!=
null
)
{
...
...
@@ -465,7 +465,7 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
// ReportCrash[37965]: Saved crash report for FlutterRunner[37941]...
runCommandAndStreamOutput
(
<
String
>[
'tail'
,
'-F'
,
'/private/var/log/system.log'
],
prefix:
'[
$name
]
'
,
prefix:
showPrefix
?
'[
$name
] '
:
'
'
,
filter:
new
RegExp
(
r' FlutterRunner\[\d+\] '
),
mapFunction:
(
String
string
)
{
Match
match
=
mapRegex
.
matchAsPrefix
(
string
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment