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
8c8bb222
Unverified
Commit
8c8bb222
authored
Oct 11, 2022
by
Jenn Magder
Committed by
GitHub
Oct 11, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BufferLogger should log stacktrace (#113240)
parent
e1f3cff2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
3 deletions
+28
-3
logger.dart
packages/flutter_tools/lib/src/base/logger.dart
+7
-1
logger_test.dart
...es/flutter_tools/test/general.shard/base/logger_test.dart
+21
-2
No files found.
packages/flutter_tools/lib/src/base/logger.dart
View file @
8c8bb222
...
...
@@ -790,8 +790,14 @@ class BufferLogger extends Logger {
bool
?
wrap
,
})
{
hadErrorOutput
=
true
;
final
StringBuffer
errorMessage
=
StringBuffer
();
errorMessage
.
write
(
message
);
if
(
stackTrace
!=
null
)
{
errorMessage
.
writeln
();
errorMessage
.
write
(
stackTrace
);
}
_error
.
writeln
(
terminal
.
color
(
wrapText
(
message
,
wrapText
(
errorMessage
.
toString
()
,
indent:
indent
,
hangingIndent:
hangingIndent
,
shouldWrap:
wrap
??
_outputPreferences
.
wrapText
,
...
...
packages/flutter_tools/test/general.shard/base/logger_test.dart
View file @
8c8bb222
...
...
@@ -3,6 +3,7 @@
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:convert'
;
import
'package:fake_async/fake_async.dart'
;
import
'package:flutter_tools/executable.dart'
;
...
...
@@ -246,12 +247,15 @@ void main() {
verboseLogger
.
printStatus
(
'Hey Hey Hey Hey'
);
verboseLogger
.
printTrace
(
'Oooh, I do I do I do'
);
verboseLogger
.
printError
(
'Helpless!'
);
final
StackTrace
stackTrace
=
StackTrace
.
current
;
verboseLogger
.
printError
(
'Helpless!'
,
stackTrace:
stackTrace
);
expect
(
mockLogger
.
statusText
,
matches
(
r'^\[ (?: {0,2}\+[0-9]{1,4} ms| )\] Hey Hey Hey Hey\n'
r'\[ (?: {0,2}\+[0-9]{1,4} ms| )\] Oooh, I do I do I do\n$'
));
expect
(
mockLogger
.
traceText
,
''
);
expect
(
mockLogger
.
errorText
,
matches
(
r'^\[ (?: {0,2}\+[0-9]{1,4} ms| )\] Helpless!\n$'
));
expect
(
mockLogger
.
errorText
,
matches
(
r'^\[ (?: {0,2}\+[0-9]{1,4} ms| )\] Helpless!\n'
));
final
String
lastLine
=
LineSplitter
.
split
(
stackTrace
.
toString
()).
toList
().
last
;
expect
(
mockLogger
.
errorText
,
endsWith
(
'
$lastLine
\n\n
'
));
});
testWithoutContext
(
'ANSI colored errors'
,
()
async
{
...
...
@@ -1239,6 +1243,21 @@ void main() {
expect
(
logger
.
statusText
,
'AAA
\n
BBB
\n
'
);
});
testWithoutContext
(
'BufferLogger prints status, trace, error'
,
()
async
{
final
BufferLogger
mockLogger
=
BufferLogger
.
test
(
outputPreferences:
OutputPreferences
.
test
(),
);
mockLogger
.
printStatus
(
'Hey Hey Hey Hey'
);
mockLogger
.
printTrace
(
'Oooh, I do I do I do'
);
final
StackTrace
stackTrace
=
StackTrace
.
current
;
mockLogger
.
printError
(
'Helpless!'
,
stackTrace:
stackTrace
);
expect
(
mockLogger
.
statusText
,
'Hey Hey Hey Hey
\n
'
);
expect
(
mockLogger
.
traceText
,
'Oooh, I do I do I do
\n
'
);
expect
(
mockLogger
.
errorText
,
'Helpless!
\n
$stackTrace
\n
'
);
});
});
}
...
...
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