mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 12:59:36 -07:00
Added log-levels to surpress unwanted error messages from console but instead we send them to the log file for further investigation later on.
This commit is contained in:
parent
b8e858cc2f
commit
ffe14122fc
2 changed files with 17 additions and 9 deletions
|
@ -16,7 +16,7 @@ ERROR = logging.ERROR
|
||||||
WARNING = logging.WARNING
|
WARNING = logging.WARNING
|
||||||
MESSAGE = logging.INFO
|
MESSAGE = logging.INFO
|
||||||
DEBUG = logging.DEBUG
|
DEBUG = logging.DEBUG
|
||||||
POSTPROCESS = 5
|
POSTPROCESS = 21
|
||||||
|
|
||||||
reverseNames = {u'ERROR': ERROR,
|
reverseNames = {u'ERROR': ERROR,
|
||||||
u'WARNING': WARNING,
|
u'WARNING': WARNING,
|
||||||
|
@ -64,13 +64,16 @@ class NTMRotatingLogHandler(object):
|
||||||
old_handler = self.cur_handler
|
old_handler = self.cur_handler
|
||||||
else:
|
else:
|
||||||
#Add a new logging level POSTPROCESS
|
#Add a new logging level POSTPROCESS
|
||||||
logging.addLevelName(5, 'POSTPROCESS')
|
logging.addLevelName(21, 'POSTPROCESS')
|
||||||
|
|
||||||
# only start consoleLogging on first initialize
|
# only start consoleLogging on first initialize
|
||||||
if self.console_logging:
|
if self.console_logging:
|
||||||
# define a Handler which writes INFO messages or higher to the sys.stderr
|
# define a Handler which writes INFO messages or higher to the sys.stderr
|
||||||
console = logging.StreamHandler()
|
console = logging.StreamHandler()
|
||||||
|
|
||||||
|
# log-level
|
||||||
|
console.setLevel(logging.INFO)
|
||||||
|
|
||||||
# set a format which is simpler for console use
|
# set a format which is simpler for console use
|
||||||
console.setFormatter(DispatchingFormatter(
|
console.setFormatter(DispatchingFormatter(
|
||||||
{'nzbtomedia': logging.Formatter('%(asctime)s %(levelname)s:: %(message)s', '%H:%M:%S'),
|
{'nzbtomedia': logging.Formatter('%(asctime)s %(levelname)s:: %(message)s', '%H:%M:%S'),
|
||||||
|
@ -102,6 +105,9 @@ class NTMRotatingLogHandler(object):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
file_handler = logging.FileHandler(self.log_file_path, encoding='utf-8')
|
file_handler = logging.FileHandler(self.log_file_path, encoding='utf-8')
|
||||||
|
|
||||||
|
file_handler.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
file_handler.setFormatter(DispatchingFormatter(
|
file_handler.setFormatter(DispatchingFormatter(
|
||||||
{'nzbtomedia': logging.Formatter('%(asctime)s %(levelname)-8s:: %(message)s', '%Y-%m-%d %H:%M:%S'),
|
{'nzbtomedia': logging.Formatter('%(asctime)s %(levelname)-8s:: %(message)s', '%Y-%m-%d %H:%M:%S'),
|
||||||
'postprocess': logging.Formatter('%(asctime)s %(levelname)-8s:: %(message)s', '%Y-%m-%d %H:%M:%S')
|
'postprocess': logging.Formatter('%(asctime)s %(levelname)-8s:: %(message)s', '%Y-%m-%d %H:%M:%S')
|
||||||
|
|
|
@ -108,7 +108,7 @@ class GitUpdateManager(UpdateManager):
|
||||||
self._num_commits_ahead = 0
|
self._num_commits_ahead = 0
|
||||||
|
|
||||||
def _git_error(self):
|
def _git_error(self):
|
||||||
logger.error('Unable to find your git executable - Set git_path in your autoProcessMedia.cfg OR delete your .git folder and run from source to enable updates.')
|
logger.debug('Unable to find your git executable - Set git_path in your autoProcessMedia.cfg OR delete your .git folder and run from source to enable updates.')
|
||||||
|
|
||||||
def _find_working_git(self):
|
def _find_working_git(self):
|
||||||
test_cmd = 'version'
|
test_cmd = 'version'
|
||||||
|
@ -153,7 +153,7 @@ class GitUpdateManager(UpdateManager):
|
||||||
logger.log(u"Not using: " + cur_git, logger.DEBUG)
|
logger.log(u"Not using: " + cur_git, logger.DEBUG)
|
||||||
|
|
||||||
# Still haven't found a working git
|
# Still haven't found a working git
|
||||||
logger.error('Unable to find your git executable - Set git_path in your autoProcessMedia.cfg OR delete your .git folder and run from source to enable updates.')
|
logger.debug('Unable to find your git executable - Set git_path in your autoProcessMedia.cfg OR delete your .git folder and run from source to enable updates.')
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ class GitUpdateManager(UpdateManager):
|
||||||
output = err = exit_status = None
|
output = err = exit_status = None
|
||||||
|
|
||||||
if not git_path:
|
if not git_path:
|
||||||
logger.log(u"No git specified, can't use git commands", logger.ERROR)
|
logger.log(u"No git specified, can't use git commands", logger.DEBUG)
|
||||||
exit_status = 1
|
exit_status = 1
|
||||||
return (output, err, exit_status)
|
return (output, err, exit_status)
|
||||||
|
|
||||||
|
@ -188,15 +188,15 @@ class GitUpdateManager(UpdateManager):
|
||||||
exit_status = 0
|
exit_status = 0
|
||||||
|
|
||||||
elif exit_status == 1:
|
elif exit_status == 1:
|
||||||
logger.log(cmd + u" returned : " + output, logger.ERROR)
|
logger.log(cmd + u" returned : " + output, logger.DEBUG)
|
||||||
exit_status = 1
|
exit_status = 1
|
||||||
|
|
||||||
elif exit_status == 128 or 'fatal:' in output or err:
|
elif exit_status == 128 or 'fatal:' in output or err:
|
||||||
logger.log(cmd + u" returned : " + output, logger.ERROR)
|
logger.log(cmd + u" returned : " + output, logger.DEBUG)
|
||||||
exit_status = 128
|
exit_status = 128
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logger.log(cmd + u" returned : " + output + u", treat as error for now", logger.ERROR)
|
logger.log(cmd + u" returned : " + output + u", treat as error for now", logger.DEBUG)
|
||||||
exit_status = 1
|
exit_status = 1
|
||||||
|
|
||||||
return (output, err, exit_status)
|
return (output, err, exit_status)
|
||||||
|
@ -296,7 +296,9 @@ class GitUpdateManager(UpdateManager):
|
||||||
return
|
return
|
||||||
|
|
||||||
def need_update(self):
|
def need_update(self):
|
||||||
self._find_installed_version()
|
if not self._find_installed_version():
|
||||||
|
logger.error("Unable to determine installed version via git, please check your logs!")
|
||||||
|
return False
|
||||||
|
|
||||||
if not self._cur_commit_hash:
|
if not self._cur_commit_hash:
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue