Modified OutputBuffer to have an error function to output to stderr. Change .fail with errors to .error

This commit is contained in:
FlyingFish
2024-05-01 23:00:25 +01:00
parent 46ec4e3edc
commit b2e621cafc
4 changed files with 25 additions and 15 deletions
+8
View File
@@ -54,6 +54,14 @@ class OutputBuffer:
self.__is_color_supported = ('colorama' in sys.modules) or (os.name == 'posix')
self.line_ended = True
def error(self, msg, line_ended=True):
"""
Writes an error message to stderr.
"""
end = '' if line_ended else '\n'
sys.stderr.write(f'{msg}{end}')
sys.stderr.flush()
def _print(self, level: str, s: str = '', line_ended: bool = True) -> None:
'''Saves output to buffer (if in buffered mode), or immediately prints to stdout otherwise.'''