mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
37 lines
855 B
Python
37 lines
855 B
Python
from __future__ import print_function
|
|
import sys
|
|
|
|
|
|
_COLOR_CODES = {
|
|
"white": '\033[0m',
|
|
"red": '\033[31m',
|
|
"green": '\033[32m',
|
|
"orange": '\033[33m',
|
|
"blue": '\033[34m',
|
|
"purple": '\033[35m',
|
|
"W": '\033[0m',
|
|
"R": '\033[31m',
|
|
"G": '\033[32m',
|
|
"O": '\033[33m',
|
|
"B": '\033[34m',
|
|
"P": '\033[35m'
|
|
}
|
|
|
|
|
|
def console_log(data, color="white", end="\n"):
|
|
"""
|
|
log data to console.
|
|
(if not flush console log, Gitlab-CI won't update logs during job execution)
|
|
|
|
:param data: data content
|
|
:param color: color
|
|
"""
|
|
if color not in _COLOR_CODES:
|
|
color = "white"
|
|
color_codes = _COLOR_CODES[color]
|
|
print(color_codes + data, end=end)
|
|
if color not in ["white", "W"]:
|
|
# reset color to white for later logs
|
|
print(_COLOR_CODES["white"] + "\r")
|
|
sys.stdout.flush()
|