Support ANSI color codes

Bart van der Schoor's Avatar

Bart van der Schoor

24 Apr, 2014 10:02 PM

It would be great if the log output would support ANSI encoding for colors. Currently we have to disable it but then we loose a lot of information (the one glance green=good - red=bad).

I'm used to using Travis CI and they manage to encode it to HTML. They support only the colors and style encoding but that is fine, cursor control get to complicated (although there is talk to support it too).

  1. Support Staff 1 Posted by Feodor Fitsner on 24 Apr, 2014 10:09 PM

    Feodor Fitsner's Avatar

    Is it for Node.js output?

  2. 2 Posted by Bart van der Sc... on 24 Apr, 2014 10:15 PM

    Bart van der Schoor's Avatar

    Yes, it is for a node.js build.

    Colors are produced by various means, I use Grunt and it uses these https://github.com/marak/colors.js/

    To compare:

    Appveyor: https://ci.appveyor.com/project/BartvanderSchoor/tsd/build/3

    Same on Travis: https://travis-ci.org/DefinitelyTyped/tsd/builds/23711876

  3. Support Staff 3 Posted by Feodor Fitsner on 24 Apr, 2014 10:50 PM

    Feodor Fitsner's Avatar

    It's Windows and the way it grabs process output. We've been investigating the problem of capturing color information from console but it seems it's too deep inside Windows and we decided to abandon that idea.

    Another thing are ESC color sequences - I wouldn't mind to give it a chance as it seems they can be processed on client side in JS.

  4. 4 Posted by Bart van der Sc... on 24 Apr, 2014 11:05 PM

    Bart van der Schoor's Avatar

    Afaik these ANSI codes are simple string codes right in the output stream: you see them in the logs. So should be possible to capture these as-is via stdout right?

    Would it matter if I use a different shell? I have ps: grunt test (PowerShell) but for no particular reason.

  5. Support Staff 5 Posted by Feodor Fitsner on 24 Apr, 2014 11:09 PM

    Feodor Fitsner's Avatar

    Yeah, I think ANSI colors can be easily processed on client side.
    Switching between shells won't make any difference - it's still running Node.js in a separate process and capturing output.

  6. 6 Posted by Bart van der Sc... on 24 Apr, 2014 11:23 PM

    Bart van der Schoor's Avatar

    Cool, will be nice.

    If you start doing client side stuff on the logs then you can some other interesting things: like making toggle-groups from boring parts of the builds and hiding them after they are done. (like npm-install is so boring to scroll through)

  7. Support Staff 7 Posted by Feodor Fitsner on 24 Apr, 2014 11:25 PM

    Feodor Fitsner's Avatar

    Yep, grouping would be nice too.

  8. Support Staff 8 Posted by Feodor Fitsner on 24 Apr, 2014 11:50 PM

    Feodor Fitsner's Avatar

    Well, well, it seems I've got some results ;)

  9. 9 Posted by Bart van der Sc... on 25 Apr, 2014 12:02 AM

    Bart van der Schoor's Avatar

    Hah, nice.

    :shipit:

  10. Support Staff 10 Posted by Feodor Fitsner on 25 Apr, 2014 01:08 AM

    Feodor Fitsner's Avatar

    Deployed!

    - Feodor

  11. 11 Posted by Bart van der Sc... on 25 Apr, 2014 03:24 AM

    Bart van der Schoor's Avatar

    Very cool, nice colors too.

    I did spot a weird edge-case:

    My build runs a node.js child process that streams back to the main process. (using grunt-shell). For some weird reason it doesn't get filtered properly:

    Compare this: https://ci.appveyor.com/project/BartvanderSchoor/tsd#L1214

    To: https://travis-ci.org/DefinitelyTyped/tsd#L1108

    (also note the log-line-deeplink to appveyor doesn't offset the scroll-position for the height of the page header :)

  12. Support Staff 12 Posted by Feodor Fitsner on 25 Apr, 2014 03:27 AM

    Feodor Fitsner's Avatar

    Yeah, that fixed header is a pain :)

    So, what's the difference between Travis and AV logs? :-/

  13. 13 Posted by Bart van der Sc... on 25 Apr, 2014 03:43 AM

    Bart van der Schoor's Avatar

    It didn't show? Weird.

    Check the attached screenshots: notice AppVeyor has a lot more cyan then Travis.

    Could be because of chunk boundaries in the stdio streams?

  14. Support Staff 14 Posted by Feodor Fitsner on 25 Apr, 2014 04:34 AM

    Feodor Fitsner's Avatar

    Oh, I see. Thanks for the catch!

    It's been incorrect handling of "reset" [0m sequence. It was fixed and updated deployed.

  15. 15 Posted by Bart van der Sc... on 25 Apr, 2014 09:30 AM

    Bart van der Schoor's Avatar

    I see it, very nice! (and good bright colors too).

  16. 16 Posted by tony on 25 Apr, 2014 10:46 PM

    tony's Avatar

    Nice, glad colors are now implemented. The old [1m*  was looking a bit messy.

  17. 17 Posted by Kirill Müller on 14 Aug, 2014 10:13 AM

    Kirill Müller's Avatar

    Thanks. Is it possible to colorize my own output with the Write-Output cmdlet in PowerShell?

  18. Support Staff 18 Posted by Feodor Fitsner on 14 Aug, 2014 03:20 PM

    Feodor Fitsner's Avatar

    You can have colorized output with Write-Host

  19. 19 Posted by Kirill Müller on 14 Aug, 2014 04:37 PM

    Kirill Müller's Avatar

    Works like a charm! For reference: WriteHost "message" -ForegroundColor Green

  20. 20 Posted by nathan.stocks on 22 Jun, 2015 07:53 PM

    nathan.stocks's Avatar

    This isn't working for me at all. What am I missing?

    My project uses colorama for colors on Windows. It works great on real Windows, but it doesn't seem to work at all on AppVeyor.

    Here's a build that should be very colorful:

    https://ci.appveyor.com/project/CleanCut/green/build/job/5k9esr3b04fwyax5

  21. 21 Posted by nathan.stocks on 22 Jun, 2015 10:34 PM

    nathan.stocks's Avatar

    I should probably clarify that colorama is a python module that handles portable terminal color codes (posix and windows).

  22. Support Staff 22 Posted by Feodor Fitsner on 23 Jun, 2015 02:10 AM

    Feodor Fitsner's Avatar

    AppVeyor can only display whatever goes to STDOUT/STDERR of the process. I guess those libraries work with console API.aspx) directly.

  23. 23 Posted by nathan.stocks on 23 Jun, 2015 02:27 AM

    nathan.stocks's Avatar

    Are you saying that instead of (colorama) stripping the ansi escape
    sequences and making the win32 calls directly, it should actually output
    the ansi escape sequences that typically don't work on windows -- but that
    appveyor will convert them?

    Here's the python library I'm using, for reference:

    https://pypi.python.org/pypi/colorama

  24. Support Staff 24 Posted by Feodor Fitsner on 23 Jun, 2015 02:44 AM

    Feodor Fitsner's Avatar

    I'm not an expert in Python but looking into this source file proves that the library uses Console API. Unfortunately, this information cannot be (easily) intercepted while running the process. Obviously, as ANSI sequences go to STDOUT they can be interpreted by AppVeyor.

  25. 25 Posted by nathan.stocks on 23 Jun, 2015 03:56 AM

    nathan.stocks's Avatar

    Thanks! With that information I was able to simply *not* turn on Windows
    ansi coloring iff we are running on Windows on Appveyor...to turn on
    colors. :-)

    https://ci.appveyor.com/project/CleanCut/green/build/job/5a01wnkd58gt2ms2

  26. 26 Posted by Nicolas on 20 Aug, 2015 09:55 AM

    Nicolas's Avatar

    Hello, I'm trying to use appveyor to test the Symfony PHP framework on Windows.
    I'm almost done, you did a wonderful job here!
    I wanted to notice you of a bug in the ansi color support:
    Only single codes are supported ( \e[1m ). Multiple codes sequences are not handled ( \e[1;2;3m ). See e.g. https://ci.appveyor.com/project/fabpot/symfony/build/1.0.72

    I worked around this current limitation by splitting multiple codes sequences to single codes, but then sometimes, colors are not correctly reseted, see e.g.:
    https://ci.appveyor.com/project/fabpot/symfony/build/1.0.74#L1256

  27. 27 Posted by Nicolas on 20 Aug, 2015 10:12 AM

    Nicolas's Avatar

    Also not that sometimes you split a log line in the middle of an ansi code (see raw log), leading the display bugs
    e.g. https://ci.appveyor.com/project/fabpot/symfony/build/1.0.74#L1022

  28. Support Staff 28 Posted by Feodor Fitsner on 20 Aug, 2015 11:06 AM

    Feodor Fitsner's Avatar

    @Nicolas What's the meaning of those multi-code sequences? Could you drop a link to more info about it?

  29. 29 Posted by Nicolas on 20 Aug, 2015 11:43 AM

    Nicolas's Avatar

    For almost all codes, this is just a way to concat several codes in one. Which means \e[1;2;3m is the same as \e[1m\e[2m\e[3m

    There are two exceptions: modes 38 and 48, which consume some numbers as parameters (but I suggest you don't implement them, at least for now, if that's too much work):
    https://en.wikipedia.org/wiki/ANSI_escape_code#graphics

  30. 30 Posted by Nicolas on 29 Sep, 2015 08:14 AM

    Nicolas's Avatar

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac