question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ANSI support in console

See original GitHub issue

Steps to Reproduce

 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
Снимок экрана 2020-08-05 в 22 24 23
  • flutter logs
Снимок экрана 2020-08-05 в 22 24 36

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:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:22 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
neoRileycommented, Feb 27, 2021

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:

  1. Install Grep Console Plugin
  2. In the output console, right click and choose “Grep” - this will bring up a tab that has an “Expression” field, type “flutter:” in there and hit “Apply”. You’ll now see all of the flutter console logging in this new tab.
  3. Add colors to possible string values in the Grep Console Settings. I added a ton that I use for logging in Unity.
  4. Then, to see the color, just append the string value to your print() call: 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.

image

2reactions
devoncarewcommented, Oct 9, 2020

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 the ColoredProcessHandler 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ANSI escape code - Wikipedia
ANSI escape sequences are a standard for in-band signaling to control cursor location, color, font styling, and other options on video text terminals...
Read more >
Use ANSI colors in the terminal - Windows CMD - SS64.com
How-to: Use ANSI colors in the terminal. ANSI colors are available by default in Windows version 1909 or newer. See below for older...
Read more >
How to test if console supports ANSI color codes?
1 Answer 1 ... On Windows you can get/set the ANSI color support by checking/setting the ENABLE_VIRTUAL_TERMINAL_PROCESSING flag with ...
Read more >
Windows console with ANSI colors handling - Super User
Ansi sequences are handled for all processes, running in ConEmu tabs. AFAIK, ConEmu supports more codes, than Ansicon. ConEmu and ANSI X3.64 / ......
Read more >
Using ANSI colour codes in .NET Core Console applications
Demonstrates how to use ANSI colour codes in .NET Core console applications, as well as the limitations of this on Windows.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found