google / ansicolor-dart

Apache License 2.0
104 stars 26 forks source link

not work on iOS (Android is fine) #24

Closed orliu closed 4 months ago

orliu commented 3 years ago

I got some logs like these on iOS:

flutter: \^[[38;5;246mI/17:21:00 flutter: \^[[38;5;246mI/17:21:00 flutter: \^[[38;5;246mI/17:21:00 flutter: \^[[38;5;246mI/17:21:00 flutter: \^[[38;5;246mI/17:21:00 flutter: \^[[38;5;246mI/17:21:00

flutter doctor: [✓] Flutter (Channel stable, 2.0.4, on Mac OS X 10.15.5 19F101 darwin-x64, locale en-AS) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2) [✓] Xcode - develop for iOS and macOS [✓] Android Studio (version 4.1) [✓] IntelliJ IDEA Ultimate Edition (version 2020.3.1) [✓] VS Code (version 1.55.2) [✓] Proxy Configuration [✓] Connected device (1 available)

flutter devices: (iphone 6p) Phone (mobile) • b6a915834fadb0f*****accbe869c39966e9f • ios • iOS 12.5.1

How can I solve this problem?

dourgulf commented 2 years ago

Same issue

petrnymsa commented 1 year ago

@orliu One year later, did you manage to solve this?

Harishwarrior commented 4 months ago

I have solved this issue

    const String RED = '\u001b[31m';
    const String GREEN = '\u001b[32m';
    const String YELLOW = '\u001b[33m';
    const String BLUE = '\u001b[34m';
    const String RESET = '\u001b[0m';

    if (Platform.isIOS) {
            String color;
            switch (log.logLevel) {
              case LogLevel.ERROR:
                color = RED;
                break;
              case LogLevel.FATAL:
                color = RED;
                break;
              case LogLevel.WARNING:
                color = YELLOW;
                break;
              case LogLevel.INFO:
                color = BLUE;
                break;
              case LogLevel.DEBUG:
              case LogLevel.TRACE:
                color = BLUE;
                break;
              default:
                color = '';
            }
            developer.log("$color${Formatter.format(log, _config)}$RESET");
   } else{
   // log using this package
   }

I am using custom logger and this works

@petrnymsa @dourgulf @orliu

jtmcdole commented 4 months ago

'\u001b[31m' is the 3bit color for ansi and the package uses 8bit color. This library was written a very long time ago; but I'm happy to take PRs.

Harishwarrior commented 4 months ago

'\u001b[31m' is the 3bit color for ansi and the package uses 8bit color. This library was written a very long time ago; but I'm happy to take PRs.

I'll research more about this and create a PR. I wonder what is happening in iOS side which causes the issue.

orliu commented 4 months ago

This issue does not affect the actual development work, it takes too long, so I will close it first