mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 21:03:14 -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
|
||||
MESSAGE = logging.INFO
|
||||
DEBUG = logging.DEBUG
|
||||
POSTPROCESS = 5
|
||||
POSTPROCESS = 21
|
||||
|
||||
reverseNames = {u'ERROR': ERROR,
|
||||
u'WARNING': WARNING,
|
||||
|
@ -64,13 +64,16 @@ class NTMRotatingLogHandler(object):
|
|||
old_handler = self.cur_handler
|
||||
else:
|
||||
#Add a new logging level POSTPROCESS
|
||||
logging.addLevelName(5, 'POSTPROCESS')
|
||||
logging.addLevelName(21, 'POSTPROCESS')
|
||||
|
||||
# only start consoleLogging on first initialize
|
||||
if self.console_logging:
|
||||
# define a Handler which writes INFO messages or higher to the sys.stderr
|
||||
console = logging.StreamHandler()
|
||||
|
||||
# log-level
|
||||
console.setLevel(logging.INFO)
|
||||
|
||||
# set a format which is simpler for console use
|
||||
console.setFormatter(DispatchingFormatter(
|
||||
{'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.setLevel(logging.DEBUG)
|
||||
|
||||
file_handler.setFormatter(DispatchingFormatter(
|
||||
{'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')
|
||||
|
|
|
@ -108,7 +108,7 @@ class GitUpdateManager(UpdateManager):
|
|||
self._num_commits_ahead = 0
|
||||
|
||||
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):
|
||||
test_cmd = 'version'
|
||||
|
@ -153,7 +153,7 @@ class GitUpdateManager(UpdateManager):
|
|||
logger.log(u"Not using: " + cur_git, logger.DEBUG)
|
||||
|
||||
# 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
|
||||
|
||||
|
@ -162,7 +162,7 @@ class GitUpdateManager(UpdateManager):
|
|||
output = err = exit_status = None
|
||||
|
||||
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
|
||||
return (output, err, exit_status)
|
||||
|
||||
|
@ -188,15 +188,15 @@ class GitUpdateManager(UpdateManager):
|
|||
exit_status = 0
|
||||
|
||||
elif exit_status == 1:
|
||||
logger.log(cmd + u" returned : " + output, logger.ERROR)
|
||||
logger.log(cmd + u" returned : " + output, logger.DEBUG)
|
||||
exit_status = 1
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
return (output, err, exit_status)
|
||||
|
@ -296,7 +296,9 @@ class GitUpdateManager(UpdateManager):
|
|||
return
|
||||
|
||||
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:
|
||||
return True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue