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
aa65fa2f
Unverified
Commit
aa65fa2f
authored
Nov 13, 2018
by
Jonah Williams
Committed by
GitHub
Nov 13, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove await for syntax from fuchsia log scanner (#24263)
parent
2e33d08d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
19 deletions
+55
-19
fuchsia_device.dart
packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
+38
-16
fuchsa_device_test.dart
packages/flutter_tools/test/fuchsia/fuchsa_device_test.dart
+17
-3
No files found.
packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
View file @
aa65fa2f
...
...
@@ -29,7 +29,6 @@ class _FuchsiaLogReader extends DeviceLogReader {
_FuchsiaLogReader
(
this
.
_device
,
[
this
.
_app
]);
static
final
RegExp
_flutterLogOutput
=
RegExp
(
r'INFO: \w+\(flutter\): '
);
static
final
RegExp
_utcDateOutput
=
RegExp
(
r'\d+\-\d+\-\d+ \d+:\d+:\d+'
);
FuchsiaDevice
_device
;
ApplicationPackage
_app
;
...
...
@@ -43,7 +42,7 @@ class _FuchsiaLogReader extends DeviceLogReader {
return
_logLines
;
}
Stream
<
String
>
_processLogs
(
Stream
<
String
>
lines
)
async
*
{
Stream
<
String
>
_processLogs
(
Stream
<
String
>
lines
)
{
// Get the starting time of the log processor to filter logs from before
// the process attached.
final
DateTime
startTime
=
systemClock
.
now
();
...
...
@@ -52,26 +51,49 @@ class _FuchsiaLogReader extends DeviceLogReader {
final
RegExp
matchRegExp
=
_app
==
null
?
_flutterLogOutput
:
RegExp
(
'INFO:
${_app.name}
\\
(flutter
\\
): '
);
await
for
(
String
line
in
lines
.
where
(
matchRegExp
.
hasMatch
))
{
// Read out the date string from the log and compare it to the current time:
// Example: 2018-11-09 01:27:45
final
String
rawDate
=
_utcDateOutput
.
firstMatch
(
line
)?.
group
(
0
);
if
(
rawDate
==
null
)
{
continue
;
}
final
DateTime
logTime
=
DateTime
.
parse
(
rawDate
);
if
(
logTime
.
millisecondsSinceEpoch
<
startTime
.
millisecondsSinceEpoch
)
{
continue
;
}
// Format log into a useful string:
yield
'[
${logTime.toLocal()}
] Flutter:
${line.split(matchRegExp).last}
'
;
}
return
Stream
<
String
>.
eventTransformed
(
lines
,
(
Sink
<
String
>
outout
)
=>
_FuchsiaLogSink
(
outout
,
matchRegExp
,
startTime
),
);
}
@override
String
toString
()
=>
name
;
}
class
_FuchsiaLogSink
implements
EventSink
<
String
>
{
_FuchsiaLogSink
(
this
.
_outputSink
,
this
.
_matchRegExp
,
this
.
_startTime
);
static
final
RegExp
_utcDateOutput
=
RegExp
(
r'\d+\-\d+\-\d+ \d+:\d+:\d+'
);
final
EventSink
<
String
>
_outputSink
;
final
RegExp
_matchRegExp
;
final
DateTime
_startTime
;
@override
void
add
(
String
line
)
{
if
(!
_matchRegExp
.
hasMatch
(
line
))
{
return
;
}
final
String
rawDate
=
_utcDateOutput
.
firstMatch
(
line
)?.
group
(
0
);
if
(
rawDate
==
null
)
{
return
;
}
final
DateTime
logTime
=
DateTime
.
parse
(
rawDate
);
if
(
logTime
.
millisecondsSinceEpoch
<
_startTime
.
millisecondsSinceEpoch
)
{
return
;
}
_outputSink
.
add
(
'[
${logTime.toLocal()}
] Flutter:
${line.split(_matchRegExp).last}
'
);
}
@override
void
addError
(
Object
error
,
[
StackTrace
stackTrace
])
{
_outputSink
.
addError
(
error
,
stackTrace
);
}
@override
void
close
()
{
_outputSink
.
close
();
}
}
class
FuchsiaDevices
extends
PollingDeviceDiscovery
{
FuchsiaDevices
()
:
super
(
'Fuchsia devices'
);
...
...
packages/flutter_tools/test/fuchsia/fuchsa_device_test.dart
View file @
aa65fa2f
...
...
@@ -126,11 +126,18 @@ d 2 0 .
final FuchsiaDevice device = FuchsiaDevice('
id
', name: '
tester
');
final DeviceLogReader reader = device.getLogReader(app: FuchsiaModulePackage(name: '
example_app
'));
final List<String> logLines = <String>[];
reader.logLines.listen(logLines.add);
final Completer<void> lock = Completer<void>();
reader.logLines.listen((String line) {
logLines.add(line);
if (logLines.length == 2) {
lock.complete();
}
});
expect(logLines, isEmpty);
stdout.add(utf8.encode(exampleUtcLogs));
await stdout.close();
await lock.future.timeout(const Duration(seconds: 1));
expect(logLines, <String>[
'
[
2018
-
11
-
09
01
:
27
:
45.000
]
Flutter:
Error
doing
thing
',
...
...
@@ -154,7 +161,7 @@ d 2 0 .
stdout.add(utf8.encode(exampleUtcLogs));
await stdout.close();
await lock.future;
await lock.future
.timeout(const Duration(seconds: 1))
;
expect(logLines, <String>[
'
[
2018
-
11
-
09
01
:
30
:
12.000
]
Flutter:
Did
thing
this
time
',
...
...
@@ -168,11 +175,18 @@ d 2 0 .
final FuchsiaDevice device = FuchsiaDevice('
id
', name: '
tester
');
final DeviceLogReader reader = device.getLogReader();
final List<String> logLines = <String>[];
reader.logLines.listen(logLines.add);
final Completer<void> lock = Completer<void>();
reader.logLines.listen((String line) {
logLines.add(line);
if (logLines.length == 3) {
lock.complete();
}
});
expect(logLines, isEmpty);
stdout.add(utf8.encode(exampleUtcLogs));
await stdout.close();
await lock.future.timeout(const Duration(seconds: 1));
expect(logLines, <String>[
'
[
2018
-
11
-
09
01
:
27
:
45.000
]
Flutter:
Error
doing
thing
',
...
...
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