mik-laj commented on a change in pull request #6998: [AIRFLOW-6404] - ANSI
color support for WebUI logger
URL: https://github.com/apache/airflow/pull/6998#discussion_r363520408
##########
File path: airflow/www/templates/airflow/ti_log.html
##########
@@ -123,8 +123,32 @@ <h4>{{ title }}</h4>
if(auto_tailing && checkAutoTailingCondition()) {
var should_scroll = true
}
+
+ // ANSI color support
+ var ansi_color_regex = /.\[([0-9][0-9])m(.*?).\[0m/gs;
+ var res.message = res.message.replace(ansi_color_regex,
function(match, color, content) {
+ var colors = {
+ 30: 'black', 40: 'black',
+ 31: 'red', 41: 'red',
+ 32: 'green', 42: 'green',
+ 33: 'yellow', 43: 'yellow',
+ 34: 'blue', 44: 'blue',
+ 35: 'magenta',45: 'magenta',
+ 36: 'cyan', 46: 'cyan',
+ 37: 'white', 47: 'white'
+ }
+
+ if (30 <= parseInt(color) && parseInt(color) <= 37) {
Review comment:
This looks good for now. In the future, I think we should move the JS code
to separate files and then download this library using npm and webpack.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services