ANSI support in console
See original GitHub issueSteps to Reproduce
-
I’m using this package https://pub.dev/packages/ansicolor
-
And print with this function
String _colorMessage(LogLevel logLevel, String message) {
AnsiPen pen;
switch (logLevel) {
case LogLevel.error:
pen = AnsiPen()..red();
break;
case LogLevel.warning:
pen = AnsiPen()..yellow();
break;
case LogLevel.debug:
pen = AnsiPen()..white();
break;
case LogLevel.trace:
pen = AnsiPen()..gray(level: 0.5);
break;
}
return pen(message);
}
- “Run” tool window
flutter logs
Version info
[✓] Flutter (Channel stable, v1.17.5, on Mac OS X 10.15.6 19G73, locale ru-RU) • Flutter version 1.17.5 at /Users/vmeretin/dev/flutter • Framework revision 8af6b2f038 (5 weeks ago), 2020-06-30 12:53:55 -0700 • Engine revision ee76268252 • Dart version 2.8.4
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.1) • Android SDK at /Users/vmeretin/dev/android-sdk/ • Platform android-29, build-tools 30.0.1 • ANDROID_HOME = /Users/vmeretin/dev/android-sdk/ • ANDROID_SDK_ROOT = /Users/vmeretin/dev/android-sdk/ • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593) • All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.6) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 11.6, Build version 11E708 • CocoaPods version 1.9.3
[!] Android Studio (version 4.0) • Android Studio at /Applications/Android Studio.app/Contents ✗ Flutter plugin not installed; this adds Flutter specific functionality. ✗ Dart plugin not installed; this adds Dart specific functionality. • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
[!] IntelliJ IDEA Ultimate Edition (version 2020.2) • IntelliJ at /Applications/IntelliJ IDEA.app ✗ Flutter plugin not installed; this adds Flutter specific functionality. ✗ Dart plugin not installed; this adds Dart specific functionality. • For information about installing plugins, see https://flutter.dev/intellij-setup/#installing-the-plugins
[✓] Connected device (1 available) • iPhone SE (2nd generation) • 2207B74B-0056-43BB-A0AD-6B97703D8176 • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-6 (simulator)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:22 (7 by maintainers)
Top GitHub Comments
Hey I appreciate everyone’s help and patience, thanks very much for that. In the end, I’m guessing being on Mac is the issue, so I went after Grep Console and that’s actually working decently well.
To anyone else coming across this on a Mac - I’m using IntelliJ IDEA Ultimate 2020.3, but I assume this works with Android Studio as well:
print("My test message [ORANGE]");
It’s the entire line and I you have to live with “[colorName]” at the end of your statements, but it does work.
From looking at this, it will require changes to the Flutter plugin (minor changes, as outlined by @alexander-doroshko above), as well as changes to the flutter command line tool. Somewhere in the pipeline it looks like we’re escaping the escape char (into
\^
?), so the ansi handling in theColoredProcessHandler
class doesn’t have the right info to act on.As part of fixing the escaping issue, we can probably also do something about the leading
flutter:
text on print output from flutter apps.