Re-enable autoreset of colour in terminal
Problem
The scheduler log would get a spurious color reset char (ESC[0m) at the start of the "DONE" line when not in no-detach mode.
This was being caused by autoreset=True being passed to
https://github.com/cylc/cylc-flow/blob/9abced91a08924bea02318839edb93a6fe2a5780/cylc/flow/terminal.py#L269-L270
and some weird interaction with the scheduler daemonization process. The "DONE" line in the log is the only line logged by scheduler_cli after the scheduler has finished running:
https://github.com/cylc/cylc-flow/blob/9abced91a08924bea02318839edb93a6fe2a5780/cylc/flow/scheduler_cli.py#L443-L445
Proposed Solution
[!NOTE]
autoresetwas set toFalsein:
- #6021 (cylc-flow 8.3.0)
Ideally we want autoreset to be set to True to ensure we don't permanently colour the terminal output by mistake. This will take some figuring out to achieve without getting the spurious reset character again.
I expect with more careful file handing around the daemonization it wouldn't happen (it shouldn't logically), e.g. close logs in the original process and re-open them in the fork?
https://github.com/cylc/cylc-flow/pull/6021#discussion_r1542620945
Just encountered this error (8.3.3), likely related:
Traceback (most recent call last):
File "/cylc/lib/python3.9/logging/__init__.py", line 1083, in emit
msg = self.format(record)
File "/cylc/lib/python3.9/logging/__init__.py", line 927, in format
return fmt.format(record)
File "/cylc/lib/python3.9/site-packages/cylc/flow/loggingutil.py", line 102, in format
text = cparse(self.COLORS[record.levelname].format(text))
File "/cylc/lib/python3.9/site-packages/ansimarkup/markup.py", line 54, in parse
text = self.re_tag.sub(lambda m: self.sub_tag(m, tags, results), text)
File "/cylc/lib/python3.9/site-packages/ansimarkup/markup.py", line 54, in <lambda>
text = self.re_tag.sub(lambda m: self.sub_tag(m, tags, results), text)
File "/cylc/lib/python3.9/site-packages/ansimarkup/markup.py", line 146, in sub_tag
raise UnbalancedTag('closing tag "%s" violates nesting rules.' % markup)
ansimarkup.markup.UnbalancedTag: closing tag "</fg #888888>" violates nesting rules.
A recent change to the scheduler_cli code (https://github.com/cylc/cylc-flow/pull/6310) should make this easier than it was before as the detatch bit is no longer inline with the rest of the code which I think may have been the issue that triggered the change away from autoreset.