alan-turing-institute / data-safe-haven

https://data-safe-haven.readthedocs.io
BSD 3-Clause "New" or "Revised" License
61 stars 15 forks source link

ANSI escape sequences in log files #2222

Closed JimMadge closed 1 month ago

JimMadge commented 1 month ago

Possibly related to changes in #2113 where colour output for Pulumi messages was restored.

The log files contain the ANSI escape sequences used to give Pulumi output colour. For example,

2024-10-04 08:45:33,279 - INFO - Refreshing stack shm-kernow-sre-resrudh.
2024-10-04 08:45:40,329 - INFO - Refreshing (shm-kernow-sre-resrudh):
2024-10-04 08:45:42,996 - INFO - 
2024-10-04 08:45:43,690 - INFO -  ~  pulumi:pulumi:Stack data-safe-haven-shm-kernow-sre-resrudh refreshing (0s)
2024-10-04 08:45:43,690 - INFO -     pulumi:pulumi:Stack data-safe-haven-shm-kernow-sre-resrudh running

Compared to previous log files

2024-07-31 09:41:50,698 - INFO - Refreshing stack shm-daimyo-sre-hojo.
2024-07-31 09:41:57,333 - INFO - Refreshing (shm-daimyo-sre-hojo):
2024-07-31 09:41:59,939 - INFO - 
2024-07-31 09:42:00,907 - INFO -  ~  pulumi:pulumi:Stack data-safe-haven-shm-daimyo-sre-hojo refreshing (0s)
2024-07-31 09:42:00,907 - INFO -     pulumi:pulumi:Stack data-safe-haven-shm-daimyo-sre-hojo running

I think we should be able to fix this by adding some functionality to the file logger to strip these (which we previously did for both the file and console loggers).