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
f4ec459c
Commit
f4ec459c
authored
Oct 08, 2015
by
Ian Fischer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for log commands on iOS.
parent
43aaf50e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
8 deletions
+45
-8
device.dart
packages/flutter_tools/lib/src/device.dart
+9
-0
logs.dart
packages/flutter_tools/lib/src/logs.dart
+15
-2
process.dart
packages/flutter_tools/lib/src/process.dart
+17
-5
logs_test.dart
packages/flutter_tools/test/logs_test.dart
+4
-1
No files found.
packages/flutter_tools/lib/src/device.dart
View file @
f4ec459c
...
...
@@ -89,6 +89,9 @@ class IOSDevice extends _Device {
String
_debuggerPath
;
String
get
debuggerPath
=>
_debuggerPath
;
String
_loggerPath
;
String
get
loggerPath
=>
_loggerPath
;
String
_name
;
String
get
name
=>
_name
;
...
...
@@ -103,6 +106,7 @@ class IOSDevice extends _Device {
_listerPath
=
_checkForCommand
(
'idevice_id'
);
_informerPath
=
_checkForCommand
(
'ideviceinfo'
);
_debuggerPath
=
_checkForCommand
(
'idevicedebug'
);
_loggerPath
=
_checkForCommand
(
'idevicesyslog'
);
}
static
List
<
IOSDevice
>
getAttachedDevices
([
IOSDevice
mockIOS
])
{
...
...
@@ -203,6 +207,11 @@ class IOSDevice extends _Device {
// Currently we don't have a way to stop an app running on iOS.
return
false
;
}
Future
<
int
>
logs
({
bool
clear:
false
})
{
return
runCommandAndStreamOutput
([
loggerPath
],
prefix:
'IOS DEV: '
,
filter:
new
RegExp
(
r'.*SkyShell.*'
));
}
}
class
AndroidDevice
extends
_Device
{
...
...
packages/flutter_tools/lib/src/logs.dart
View file @
f4ec459c
...
...
@@ -15,9 +15,10 @@ 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
;
AndroidDevice
android
;
IOSDevice
ios
;
LogsCommand
(
[
this
.
android
]
)
{
LogsCommand
(
{
this
.
android
,
this
.
ios
}
)
{
argParser
.
addFlag
(
'clear'
,
negatable:
false
,
help:
'Clear log history before reading from logs (Android only).'
);
...
...
@@ -28,16 +29,28 @@ class LogsCommand extends Command {
if
(
android
==
null
)
{
android
=
new
AndroidDevice
();
}
if
(
ios
==
null
)
{
ios
=
new
IOSDevice
();
}
Future
<
int
>
androidLogProcess
=
null
;
if
(
android
.
isConnected
())
{
androidLogProcess
=
android
.
logs
(
clear:
argResults
[
'clear'
]);
}
Future
<
int
>
iosLogProcess
=
null
;
if
(
ios
.
isConnected
())
{
iosLogProcess
=
ios
.
logs
(
clear:
argResults
[
'clear'
]);
}
if
(
androidLogProcess
!=
null
)
{
await
androidLogProcess
;
}
if
(
iosLogProcess
!=
null
)
{
await
iosLogProcess
;
}
return
0
;
}
}
packages/flutter_tools/lib/src/process.dart
View file @
f4ec459c
...
...
@@ -15,15 +15,27 @@ final Logger _logging = new Logger('sky_tools.process');
/// This runs the command and streams stdout/stderr from the child process to
/// this process' stdout/stderr.
Future
<
int
>
runCommandAndStreamOutput
(
List
<
String
>
cmd
,
{
String
prefix:
''
})
async
{
{
String
prefix:
''
,
RegExp
filter
})
async
{
_logging
.
info
(
cmd
.
join
(
' '
));
Process
proc
=
await
Process
.
start
(
cmd
[
0
],
cmd
.
getRange
(
1
,
cmd
.
length
).
toList
());
proc
.
stdout
.
transform
(
UTF8
.
decoder
).
listen
((
data
)
{
stdout
.
write
(
'
$prefix${data.trimRight().split('\n').join('\n$prefix')}
\n
'
);
proc
.
stdout
.
transform
(
UTF8
.
decoder
).
listen
((
String
data
)
{
List
<
String
>
dataLines
=
data
.
trimRight
().
split
(
'
\n
'
);
if
(
filter
!=
null
)
{
dataLines
=
dataLines
.
where
((
String
s
)
=>
filter
.
hasMatch
(
s
));
}
if
(
dataLines
.
length
>
0
)
{
stdout
.
write
(
'
$prefix${dataLines.join('\n$prefix')}
\n
'
);
}
});
proc
.
stderr
.
transform
(
UTF8
.
decoder
).
listen
((
data
)
{
stderr
.
write
(
'
$prefix${data.trimRight().split('\n').join('\n$prefix')}
\n
'
);
proc
.
stderr
.
transform
(
UTF8
.
decoder
).
listen
((
String
data
)
{
List
<
String
>
dataLines
=
data
.
trimRight
().
split
(
'
\n
'
);
if
(
filter
!=
null
)
{
dataLines
=
dataLines
.
where
((
String
s
)
=>
filter
.
hasMatch
(
s
));
}
if
(
dataLines
.
length
>
0
)
{
stderr
.
write
(
'
$prefix${dataLines.join('\n$prefix')}
\n
'
);
}
});
return
proc
.
exitCode
;
}
...
...
packages/flutter_tools/test/logs_test.dart
View file @
f4ec459c
...
...
@@ -20,7 +20,10 @@ defineTests() {
MockAndroidDevice
android
=
new
MockAndroidDevice
();
when
(
android
.
isConnected
()).
thenReturn
(
false
);
LogsCommand
command
=
new
LogsCommand
(
android
);
MockIOSDevice
ios
=
new
MockIOSDevice
();
when
(
ios
.
isConnected
()).
thenReturn
(
false
);
LogsCommand
command
=
new
LogsCommand
(
android:
android
,
ios:
ios
);
CommandRunner
runner
=
new
CommandRunner
(
'test_flutter'
,
''
)
..
addCommand
(
command
);
...
...
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