SourceHorizon / logger

Small, easy to use and extensible logger which prints beautiful logs.
https://pub.dev/packages/logger
MIT License
197 stars 33 forks source link

iOS: Colors not working #18

Closed g0dzillaa closed 1 year ago

g0dzillaa commented 1 year ago

I was trying to understand why colors are not supported in VSCode and read the comment in the ReadMe.md

Please note that all IDEs (VSCode, XCode, Android Studio, IntelliJ) do not support ANSI escape sequences in their terminal outputs. These escape sequences are used to color output. If using such an IDE do not configure colored output.

However, one of the dev_dependencies that I am using is working perfectly with colors!

Any idea why this is not working for main project?

This is the dev dependency: https://pub.dev/packages/pubspec_dependency_sorter

Screenshot 2023-04-15 at 11 54 28 PM
Bungeefan commented 1 year ago

Did you try the logger color output in your VSCode? I am using Android Studio and can confirm that it indeed does work in the IDE, I am guessing this was true in the past or for specific versions.

g0dzillaa commented 1 year ago

@Bungeefan I am not sure how to do that. What I meant was, it is working fine for a dev dependency but not in the main dependency.

Bungeefan commented 1 year ago

I was trying to find out if you only assumed that it doesn't work because of the (possibly old) comment in the README, or if you really tried it in your VSCode, and it didn't work?

g0dzillaa commented 1 year ago

@Bungeefan I did try and I can confirm that this is the case. I added the dev dependency lately and figured that for some reasons, the colors are working there!

Happy to help with any additional information that help debug this but I think if you just install the https://pub.dev/packages/pubspec_dependency_sorter dev package on an flutter project, you can easily find the difference.

Bungeefan commented 1 year ago

Sorry for the slow replies, I haven't had as much time lately as I would have liked.

Anyways, I installed VS Code and tried to replicate your problem. I tried the following:

In all three instances, the colors of the logger packages were fully working for me. In the first case I looked in the debug console in VS Code and in the other two I used the terminal provided by VS Code.

Settings that I used: Besides some non-important settings from VS Code (like keyboard layout) these were the only settings defined in my settings.json. Which were automatically applied by the Dart plugin when using "Use recommended settings".

    "[dart]": {
        "editor.formatOnSave": true,
        "editor.formatOnType": true,
        "editor.rulers": [
            80
        ],
        "editor.selectionHighlight": false,
        "editor.suggest.snippetsPreventQuickSuggestions": false,
        "editor.suggestSelection": "first",
        "editor.tabCompletion": "onlySnippets",
        "editor.wordBasedSuggestions": false
    },

Launch config:

        {
            "name": "test",
            "request": "launch",
            "type": "dart"
        },

I tested this on a Linux machine and couldn't identify any problems, especially with any colors. Additionally, a colleague of mine uses VS Code on Windows and also had no problems with the colors of this package.

Bungeefan commented 1 year ago

@g0dzillaa Are you by any chance using macOS? I was able to test the colors on a recent version of macOS and summarized my findings in the README (d672c9c4cc205651f02df8f1b301ad88af2ac156).

g0dzillaa commented 1 year ago

Hey @Bungeefan,

Yes, I am using macOS. It's interesting that the dev dependencies work without a problem and they are consistent too.

Bungeefan commented 1 year ago

@g0dzillaa Now that I think about it, it makes perfect sense. xD

dev_dependecies are executed using dart run, therefore they run under the OS of your development device, not your mobile device. On the opposite, Flutter (with all of your dependencies) runs on the deployed device (like in your case an iOS device) and the flutter bug seems to break the colors when streaming the log output from an iOS device. Therefore, the iOS color bug does not affect your dev dependency running under macOS.

As this is not a logger bug, I am going to go ahead and close this issue now. If you disagree, just ping me and I will reopen it.

g0dzillaa commented 1 year ago

Thanks. That makes sense to me. Do you have any links to the flutter issue?

Bungeefan commented 1 year ago

Oh sorry, sure, it was linked in the README: https://github.com/flutter/flutter/issues/64491

BenjiFarquhar commented 2 months ago

Pretty good workaround until the bug is fixed: https://github.com/flutter/flutter/issues/64491#issuecomment-1873673674