change logging level of traceback messages
This commit is contained in:
parent
b7462d438a
commit
9981601a0a
6 changed files with 20 additions and 13 deletions
|
@ -73,7 +73,14 @@ class JsonFormatter(logging.Formatter):
|
|||
|
||||
|
||||
def traceback_formatter(*args, **kwargs):
|
||||
logging.getLogger('WakaTime').error(traceback.format_exc())
|
||||
if 'level' in kwargs and (kwargs['level'].lower() == 'warn' or kwargs['level'].lower() == 'warning'):
|
||||
logging.getLogger('WakaTime').warning(traceback.format_exc())
|
||||
elif 'level' in kwargs and kwargs['level'].lower() == 'info':
|
||||
logging.getLogger('WakaTime').info(traceback.format_exc())
|
||||
elif 'level' in kwargs and kwargs['level'].lower() == 'debug':
|
||||
logging.getLogger('WakaTime').debug(traceback.format_exc())
|
||||
else:
|
||||
logging.getLogger('WakaTime').error(traceback.format_exc())
|
||||
|
||||
|
||||
def set_log_level(logger, args):
|
||||
|
|
|
@ -44,9 +44,9 @@ class Git(BaseProject):
|
|||
with open(head, 'r', encoding=sys.getfilesystemencoding()) as fh:
|
||||
return u(fh.readline().strip().rsplit('/', 1)[-1])
|
||||
except:
|
||||
log.traceback()
|
||||
log.traceback('warn')
|
||||
except IOError: # pragma: nocover
|
||||
log.traceback()
|
||||
log.traceback('warn')
|
||||
return None
|
||||
|
||||
def _project_base(self):
|
||||
|
|
|
@ -42,9 +42,9 @@ class Mercurial(BaseProject):
|
|||
with open(branch_file, 'r', encoding=sys.getfilesystemencoding()) as fh:
|
||||
return u(fh.readline().strip().rsplit('/', 1)[-1])
|
||||
except:
|
||||
log.traceback()
|
||||
log.traceback('warn')
|
||||
except IOError: # pragma: nocover
|
||||
log.traceback()
|
||||
log.traceback('warn')
|
||||
return u('default')
|
||||
|
||||
def _find_hg_config_dir(self, path):
|
||||
|
|
|
@ -41,9 +41,9 @@ class WakaTimeProjectFile(BaseProject):
|
|||
self._project_name = u(fh.readline().strip())
|
||||
self._project_branch = u(fh.readline().strip())
|
||||
except:
|
||||
log.traceback()
|
||||
log.traceback('warn')
|
||||
except IOError: # pragma: nocover
|
||||
log.traceback()
|
||||
log.traceback('warn')
|
||||
|
||||
return True
|
||||
return False
|
||||
|
|
|
@ -57,7 +57,7 @@ class SessionCache(object):
|
|||
conn.commit()
|
||||
conn.close()
|
||||
except: # pragma: nocover
|
||||
log.traceback()
|
||||
log.traceback('debug')
|
||||
|
||||
|
||||
def get(self):
|
||||
|
@ -72,7 +72,7 @@ class SessionCache(object):
|
|||
try:
|
||||
conn, c = self.connect()
|
||||
except:
|
||||
log.traceback()
|
||||
log.traceback('debug')
|
||||
return requests.session()
|
||||
|
||||
session = None
|
||||
|
@ -83,12 +83,12 @@ class SessionCache(object):
|
|||
if row is not None:
|
||||
session = pickle.loads(row[0])
|
||||
except: # pragma: nocover
|
||||
log.traceback()
|
||||
log.traceback('debug')
|
||||
|
||||
try:
|
||||
conn.close()
|
||||
except: # pragma: nocover
|
||||
log.traceback()
|
||||
log.traceback('debug')
|
||||
|
||||
return session if session is not None else requests.session()
|
||||
|
||||
|
@ -105,4 +105,4 @@ class SessionCache(object):
|
|||
conn.commit()
|
||||
conn.close()
|
||||
except:
|
||||
log.traceback()
|
||||
log.traceback('debug')
|
||||
|
|
|
@ -191,5 +191,5 @@ def get_file_contents(file_name):
|
|||
with open(file_name, 'r', encoding=sys.getfilesystemencoding()) as fh:
|
||||
text = fh.read(512000)
|
||||
except:
|
||||
log.traceback()
|
||||
log.traceback('debug')
|
||||
return text
|
||||
|
|
Loading…
Reference in a new issue