Bug 1250080

Summary: [RFE] make ANSI color coding of output optional
Product: [Fedora] Fedora Reporter: Ales Zelinka <azelinka>
Component: beakerlibAssignee: Dalibor Pospíšil <dapospis>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: low    
Version: rawhideCC: azelinka, bpeck, dapospis, dkutalek, mjia, mkyral, ohudlick, optak
Target Milestone: ---Keywords: FutureFeature
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-05-07 11:49:39 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 483014    
Bug Blocks:    

Description Ales Zelinka 2015-08-04 13:27:22 UTC
restraint uses ANSI color coding in the logs even if the user/consumer expects plain text. This makes logs hard to read and parse.

:: [[0;32m   PASS   [0m] :: Creating tmp directory (Expected 0, got 0)
:: [[0;32m   PASS   [0m] :: Command 'chmod a+rx /tmp/tmp.sonUBNhf6Z' (Expected 0, got 0)
:: [[0;32m   PASS   [0m] :: Command 'skfjhxshg=/tmp/tmp.sonUBNhf6Z' (Expected 0, got 0)

Comment 2 Dan Callaghan 2015-08-05 04:02:52 UTC
I think the coloured output here is actually coming from beakerlib, right? Beakerlib thinks it's writing to a terminal because restraint runs tests attached to a pty, even though it's really just saving the output to a log file.

Comment 3 Bill Peck 2015-08-10 17:51:02 UTC
Maybe we could set a env variable that beakerlib could use to disable the ansi color when set.

  #@staticmethod
  def printLog(message, prefix="LOG"):
    color = uncolor = ""
    if sys.stdout.isatty() and prefix in ("PASS", "FAIL", "INFO", "WARNING"):
      color = termColors[prefix]
      uncolor = "\033[0m"


would need to be updated..

Comment 4 Ales Zelinka 2015-08-14 12:25:37 UTC
(In reply to Dan Callaghan from comment #2)
> I think the coloured output here is actually coming from beakerlib, right?

right. reassigning again...

Comment 5 Dalibor Pospíšil 2015-08-14 14:57:51 UTC
This could be also done together with bz483014.

Comment 6 Peter Hostačný 2016-02-18 23:42:52 UTC
@azelinka: Is this bug only restraint related ? (Do you think this feature is needed at beakerlib even if this will be resolved in restraint ?)

Comment 7 Ales Zelinka 2016-02-19 16:00:38 UTC
this was filed against restraint by mistake, it's beakerlib bug that should be fixed in beakerlib. AFAIK.

Comment 8 Jakub Prokes 2016-02-22 11:07:19 UTC
In my opinion the root of problem is in terminal checking, because there isn't check for env. variable TERM for compatible terminal (xterm* or vt100).

Comment 9 Dalibor Pospíšil 2019-05-07 11:49:39 UTC
coloring is now limitted to specific terminals