YoutubeDL: If the logger is set call its `warning` method in `report_warning`

This commit is contained in:
Jaime Marquínez Ferrándiz 2014-03-09 14:53:07 +01:00
parent edb7fc5435
commit 6d07ce0162
1 changed files with 8 additions and 5 deletions

View File

@ -370,12 +370,15 @@ class YoutubeDL(object):
Print the message to stderr, it will be prefixed with 'WARNING:' Print the message to stderr, it will be prefixed with 'WARNING:'
If stderr is a tty file the 'WARNING:' will be colored If stderr is a tty file the 'WARNING:' will be colored
''' '''
if self._err_file.isatty() and os.name != 'nt': if self.params.get('logger') is not None:
_msg_header = '\033[0;33mWARNING:\033[0m' self.params['logger'].warning(message)
else: else:
_msg_header = 'WARNING:' if self._err_file.isatty() and os.name != 'nt':
warning_message = '%s %s' % (_msg_header, message) _msg_header = '\033[0;33mWARNING:\033[0m'
self.to_stderr(warning_message) else:
_msg_header = 'WARNING:'
warning_message = '%s %s' % (_msg_header, message)
self.to_stderr(warning_message)
def report_error(self, message, tb=None): def report_error(self, message, tb=None):
''' '''