-
Notifications
You must be signed in to change notification settings - Fork 130
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 in Android Studio #2
Comments
Is this on Android or iOS? It may be related to #1 |
I have the same issue. Could it be due to Android Studio? Maybe coloured output is not supported there and only works with Visual Studio Code. EDIT: I worked on a custom logger myself before I found your much better work 😁. There I tried various ways out to colour the console output, but nothing worked. That's why I guess it is an issue with Android Studio. |
@phpmaple @Tyxz I'm working on a solution but this could take some time. In the meantime you can try out the new on device console or disable colors: var logger = Logger(
printer: PrettyPrinter(
colors: false,
) |
Hey, this tool is absolutely excellent, but unfortunately i am using Android Studio. Will u fix the ansi-color problem in Android Studio? |
@Creolophus Yes, I'm currently working on a solution. |
@leisim Hi, any news?) |
Sorry have been busy with hive lately. |
Congrats, awesome project 🤘 |
@leisim Same problem on Ubuntu Android Studio, is it related to fonts configuration? Emojis also don't work. |
The terminal in IntelliJ works just fine. I guess it's an issue w/ the console (the thing that appears when you hit run). |
While we wait for a fix, you can work around temporarily using the Grep Console plugin: you can configure it to search for the following expressions:
and choose background/foreground colors of your choose. It's a little workaround, I know, but hey, as long as it works! |
That's really creative! |
tks! |
@leisim Hello, thanks for all, it's very usefull. It's a good solution but ANSI code's stay in console and it's not very beautifull. So, I found a quick solution. Replace ANSI codes by strings like ERROR, FATAL, WARNING.... and add a boolean to set if we prefere to see labels or colors. pretty_printer.dart
ansi_color.dart
|
Hi all - so I came up with a slightly tweaked workaround for this as well. I wrote a class PrefixPrinter extends LogPrinter {
final LogPrinter _realPrinter;
Map<Level, String> _prefixMap;
PrefixPrinter(this._realPrinter,
{debug, verbose, wtf, info, warning, error, nothing}) : super() {
_prefixMap = {
Level.debug: debug ?? ' DEBUG ',
Level.verbose: verbose ?? 'VERBOSE ',
Level.wtf: wtf ?? ' WTF ',
Level.info: info ?? ' INFO ',
Level.warning: warning ?? 'WARNING ',
Level.error: error ?? ' ERROR ',
Level.nothing: nothing ?? 'NOTHING',
};
}
@override
List<String> log(LogEvent event) {
return _realPrinter.log(event).map((s) => '${_prefixMap[event.level]}$s').toList();
}
} So using that you could create a printer like: PrefixPrinter(PrettyPrinter(colors: false)); and you don't have to grep (or see) the ansi strings or copy/change the existing |
so do i have to customize the classes to fix this issue? |
@mohadel92 The solution I mention included some classes that were merged and released in 0.9.2. You can check out the pull request that has some examples of how you'd use this in #44 But the idea was that you don't have to customize the classes, this additional class just decorates the existing. Here is a simple example: final logger = Logger(
printer: PrefixPrinter(
PrettyPrinter(
methodCount: 2,
colors: false,
printTime: true
)
)
); Then you just need to grep the prefixes (see README). Note this was specifically targeting AndroidStudio / JetBrains IDEs. |
Thanks @PandaProgParis it's working with me perfectly 👍 |
^[[38;5;196m⛔ - FormatException: Unexpected end of input (at character 1)
[11:10:59 AM]: <== ^
The text was updated successfully, but these errors were encountered: