Uploaded image for project: 'Bamboo Data Center'
  1. Bamboo Data Center
  2. BAM-10855

Convert ANSI color codes to HTML when displaying logs

    XMLWordPrintable

Details

    • Our product teams collect and evaluate feedback from a number of different sources. To learn more about how we use customer feedback in the planning process, check out our new feature policy.

    Description

      The puppet output, for instance, includes ascii color escape codes which cause the usual Linux terminal to color the output.
      e.g.

      ^[[0;32minfo: Loading facts in basebuildsystemfacts^[[0m
      

      Will cause the text "info: Loading facts in basebuildsystemfacts" to be displayed in green.

      My suggestion is to identify such sequences in the log output and if they make sense (e.g. every color start tag (e.g. "[[0;32m" above) is matched by a "close tag" ("[[0m") then start paying attention to them and convert to HTML <div style="color:green"...> tags.
      Add a UI option to turn this on and off.
      The idea of disabling it and making sure that tags make sense is that if the log really contains some binary junk which happens to look like color codes then it'll be possible to see it as it is.

      I haven't found Java implementation for this but here are a couple of links to code which does this in other languages:

      1. Stackoverflow discussion: http://stackoverflow.com/questions/245121/a-library-to-convert-ansi-escapes-terminal-formatting-color-codes-to-html
      2. C program (page in German, but links to C source code): http://ziz.delphigl.com/tool_aha.php
      3. Perl module: http://search.cpan.org/~nuffin/HTML-FromANSI/lib/HTML/FromANSI.pm

      Attachments

        Issue Links

          Activity

            People

              dhernandez DavidA (Inactive)
              ashapira AmosA
              Votes:
              1 Vote for this issue
              Watchers:
              14 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: