From 5209797cb1ab0b5a562e8e55a778c172bfda7f66 Mon Sep 17 00:00:00 2001 From: Brian Turek Date: Fri, 24 Apr 2020 07:41:12 +0100 Subject: [PATCH] Remove ERROR: prefix on messages if logger is set --- youtube_dl/YoutubeDL.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 19370f62b..3ac8e334c 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -614,14 +614,17 @@ class YoutubeDL(object): def report_error(self, message, tb=None): ''' - Do the same as trouble, but prefixes the message with 'ERROR:', colored + Do the same as trouble, but prefixes the message with 'ERROR:' if logger is not set, colored in red if stderr is a tty file. ''' - if not self.params.get('no_color') and self._err_file.isatty() and compat_os_name != 'nt': - _msg_header = '\033[0;31mERROR:\033[0m' + if self.params.get('logger') is not None: + error_message = message else: - _msg_header = 'ERROR:' - error_message = '%s %s' % (_msg_header, message) + if not self.params.get('no_color') and self._err_file.isatty() and compat_os_name != 'nt': + _msg_header = '\033[0;31mERROR:\033[0m' + else: + _msg_header = 'ERROR:' + error_message = '%s %s' % (_msg_header, message) self.trouble(error_message, tb) def report_file_already_downloaded(self, file_name):