Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colors not working on iOS #1

Open
vico-aguado opened this issue Jun 5, 2019 · 24 comments
Open

Colors not working on iOS #1

vico-aguado opened this issue Jun 5, 2019 · 24 comments
Labels
bug Something isn't working

Comments

@vico-aguado
Copy link

vico-aguado commented Jun 5, 2019

Hi!!

I try in iOS and the log show this:

│ #1   _FutureBuilderState.build (package:flutter/src/widgets/async.dart)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄\^[[<…>
flutter: │ 🐛 Log message with 2 methods\^[[<…>
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────\^[[<…>
flutter: \^[[38;5;12m┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<…>
flutter: \^[[38;5;12m│ 💡 Info message<…>
flutter: \^[[38;5;12m└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<…>
flutter: \^[[38;5;208m┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<…>
flutter: \^[[38;5;208m│ ⚠️ Just a warning!<…>
flutter: \^[[38;5;208m└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<…>
flutter: \^[[38;5;196m┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<…>
flutter: \^[[38;5;196m│ \^[[0m\^[[39m\^[[48;5;196mTest Error<…>
flutter: \^[[38;5;196m├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄<…>
flutter: \^[[38;5;196m│ #0   MyPage.build.() (package:_app/src/sections/my_page.dart:55:3<…>
flutter: \^[[38;5;196m│ #1   _FutureBuilderState.build (package:flutter/src/widgets/async.dar<…>
flutter: \^[[38;5;196m├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄<…>
flutter: \^[[38;5;196m│ ⛔ Error! Something bad happened<…>
flutter: \^[[38;5;196m└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<…>
flutter: \^[[38;5;199m┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<…>
flutter: \^[[38;5;199m│ #0   MyPage.build.() (package:_app/src/sections/my_page.dart:57:3<…>
flutter: \^[[38;5;199m│ #1   _FutureBuilderState.build (package:flutter/src/widgets/async.dar<…>
flutter: \^[[38;5;199m├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄<…>
flutter: \^[[38;5;199m│ 👾 What a terrible failure log<…>
flutter: \^[[38;5;199m└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<…>
@simc
Copy link
Owner

simc commented Jun 5, 2019

Oh no, I didn't try it on iOS yet.

Do you use Xcode or VSCode?

@simc simc added the bug Something isn't working label Jun 5, 2019
@vico-aguado
Copy link
Author

I use both, but more often VSCode

@simc
Copy link
Owner

simc commented Jun 5, 2019

And do you see this problem in Xcode or VSCode?

Xcode does not support colors but in VSCode it should work fine.

@vico-aguado
Copy link
Author

vico-aguado commented Jun 5, 2019

I see this problem in both :(

@simc
Copy link
Owner

simc commented Jun 5, 2019

Okay thank you! I'll test it.

@simc
Copy link
Owner

simc commented Jun 5, 2019

I may take a little longer to fix this problem. In the meantime I added a parameter to the PrettyPrinter to disable colors.

@simc simc changed the title on iOS does not work very well Colors not working on iOS Jul 5, 2019
@priezz
Copy link

priezz commented Nov 18, 2019

@leisim Any progress on that? Package is really useful, but the output becomes unreadable when debugging on iOS.

@haarts
Copy link
Collaborator

haarts commented Dec 4, 2019

I don't think XCode supports colors: https://stackoverflow.com/questions/40583721/print-to-console-log-with-color.
The mentioned XcodeColors project seems only to work for XCode < 9.x.
Your safest best seems to pass the colors=false arg to the constructor.

@emersonsiega
Copy link

I'm using VSCode and have the same problem...

image

@haarts
Copy link
Collaborator

haarts commented Jan 31, 2020

Colors will never work in IDE terminals. None support ANSI escape codes. Passing colors: false to the constructor of PrettyPrinter at least gets rid of the garbage.

@kuhnroyal
Copy link

Colors will never work in IDE terminals. None support ANSI escape codes. Passing colors: false to the constructor of PrettyPrinter at least gets rid of the garbage.

That is not completely correct, flutter doctor works with colors in VSCode and IntelliJ. So it seems like some double encoding or escaping is happening.

@robrichardson13
Copy link

I'm not sure why, but on one project the colors work perfectly, but on another, they don't work. I haven't figured out the difference yet.

@daverin
Copy link

daverin commented Jul 1, 2021

Has anyone figured this out?

I went through this article and managed to get colors working in the Debug Console (Vscode MacOS).

Screenshot 2021-07-01 at 15 31 47

Seems the issue is related to bad escaping as suggested by @kuhnroyal.

@aliak00
Copy link

aliak00 commented Aug 8, 2021

This seems to be an issue in the flutter library, not logger: flutter/flutter#20663

@yushihang
Copy link

This issue is a bit complex, but we could solve it by changing logger/outputs/console_output.dart to below:

import 'dart:io';
import 'dart:developer' as developer;
import 'package:flutter/foundation.dart';
import 'package:idealab/plugins/logger/log_output.dart';
import 'package:idealab/plugins/logger/logger.dart';

const bool _kReleaseMode = kReleaseMode;
/// Default implementation of [LogOutput].
///
/// It sends everything to the system console.
class ConsoleOutput extends LogOutput {
@OverRide
void output(OutputEvent event) {
if (_kReleaseMode || !Platform.isIOS )
{
event.lines.forEach(debugPrint);
}
else
{
event.lines.forEach(developer.log);
}

}
}

@jacobokoenig
Copy link

Is there any news on this point? I'd love to have colored outputs using VSCode. Maybe there's a plugin to fix that?

@haarts
Copy link
Collaborator

haarts commented Jun 3, 2022

A plugin in VSCode that would enable ASNI colors would work indeed.

@Espero1995
Copy link

This issue is a bit complex, but we could solve it by changing logger/outputs/console_output.dart to below:

import 'dart:io'; import 'dart:developer' as developer; import 'package:flutter/foundation.dart'; import 'package:idealab/plugins/logger/log_output.dart'; import 'package:idealab/plugins/logger/logger.dart';

const bool _kReleaseMode = kReleaseMode; /// Default implementation of [LogOutput]. /// /// It sends everything to the system console. class ConsoleOutput extends LogOutput { @OverRide void output(OutputEvent event) { if (_kReleaseMode || !Platform.isIOS ) { event.lines.forEach(debugPrint); } else { event.lines.forEach(developer.log); }

} }

Nice, This method successfully solves the problem of no color in iOS. You should save this file, and run again, then it will take effect.

@strongwill01
Copy link

strongwill01 commented Aug 4, 2022

image

flutter: \^[[38;5;12mThis, eg[statusCode]: 200<…>
flutter: \^[[38;5;12mThis, eg[statusMessage]: OK<…>

This is my message output.

@xiaoLit
Copy link

xiaoLit commented Oct 15, 2022

image

flutter: \^[[38;5;12mThis, eg[statusCode]: 200<…>
flutter: \^[[38;5;12mThis, eg[statusMessage]: OK<…>

This is my message output.

same to me

@Thaimay
Copy link

Thaimay commented Oct 24, 2022

This issue is a bit complex, but we could solve it by changing logger/outputs/console_output.dart to below:

import 'dart:io'; import 'dart:developer' as developer; import 'package:flutter/foundation.dart'; import 'package:idealab/plugins/logger/log_output.dart'; import 'package:idealab/plugins/logger/logger.dart';

const bool _kReleaseMode = kReleaseMode; /// Default implementation of [LogOutput]. /// /// It sends everything to the system console. class ConsoleOutput extends LogOutput { @OverRide void output(OutputEvent event) { if (_kReleaseMode || !Platform.isIOS ) { event.lines.forEach(debugPrint); } else { event.lines.forEach(developer.log); }

} }

CleanShot 2022-10-24 at 09 57 06@2x

Thanks it works!!

@tanhnv-avnon
Copy link

Thank you. It works 🚀

@friebetill
Copy link

friebetill commented Jun 8, 2023

IMHO, not 100% clear, but you have to create an object of the class ConsoleOutput and assign it to the Logger constructor.

import 'dart:developer' as developer;

import 'package:flutter/foundation.dart';
import 'package:logger/logger.dart';
import 'package:universal_io/io.dart';

Logger logger = Logger(output: ConsoleOutput());

/// Extends 'LogOutput' to correctly display console colors on macOS systems.
///
/// The behavior is determined by the application's run mode (Release or Debug)
/// and the operating platform (iOS or non-iOS).
///
/// For more information, see: https://github.com/simc/logger/issues/1#issuecomment-1582076726
class ConsoleOutput extends LogOutput {
  @override
  void output(OutputEvent event) {
    if (kReleaseMode || !Platform.isIOS) {
      event.lines.forEach(debugPrint);
    } else {
      event.lines.forEach(developer.log);
    }
  }
}

@colbymaloy
Copy link

not sure why but this works, thanks! colors worked on android but not iOS. this fixes the logs on IOS. thanks

IMHO, not 100% clear, but you have to create an object of the class ConsoleOutput and assign it to the Logger constructor.

import 'dart:developer' as developer;

import 'package:flutter/foundation.dart';
import 'package:logger/logger.dart';
import 'package:universal_io/io.dart';

Logger logger = Logger(output: ConsoleOutput());

/// Extends 'LogOutput' to correctly display console colors on macOS systems.
///
/// The behavior is determined by the application's run mode (Release or Debug)
/// and the operating platform (iOS or non-iOS).
///
/// For more information, see: https://github.com/simc/logger/issues/1#issuecomment-1582076726
class ConsoleOutput extends LogOutput {
  @override
  void output(OutputEvent event) {
    if (kReleaseMode || !Platform.isIOS) {
      event.lines.forEach(debugPrint);
    } else {
      event.lines.forEach(developer.log);
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests