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):
|
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):
|
def set_log_level(logger, args):
|
||||||
|
|
|
@ -44,9 +44,9 @@ class Git(BaseProject):
|
||||||
with open(head, 'r', encoding=sys.getfilesystemencoding()) as fh:
|
with open(head, 'r', encoding=sys.getfilesystemencoding()) as fh:
|
||||||
return u(fh.readline().strip().rsplit('/', 1)[-1])
|
return u(fh.readline().strip().rsplit('/', 1)[-1])
|
||||||
except:
|
except:
|
||||||
log.traceback()
|
log.traceback('warn')
|
||||||
except IOError: # pragma: nocover
|
except IOError: # pragma: nocover
|
||||||
log.traceback()
|
log.traceback('warn')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _project_base(self):
|
def _project_base(self):
|
||||||
|
|
|
@ -42,9 +42,9 @@ class Mercurial(BaseProject):
|
||||||
with open(branch_file, 'r', encoding=sys.getfilesystemencoding()) as fh:
|
with open(branch_file, 'r', encoding=sys.getfilesystemencoding()) as fh:
|
||||||
return u(fh.readline().strip().rsplit('/', 1)[-1])
|
return u(fh.readline().strip().rsplit('/', 1)[-1])
|
||||||
except:
|
except:
|
||||||
log.traceback()
|
log.traceback('warn')
|
||||||
except IOError: # pragma: nocover
|
except IOError: # pragma: nocover
|
||||||
log.traceback()
|
log.traceback('warn')
|
||||||
return u('default')
|
return u('default')
|
||||||
|
|
||||||
def _find_hg_config_dir(self, path):
|
def _find_hg_config_dir(self, path):
|
||||||
|
|
|
@ -41,9 +41,9 @@ class WakaTimeProjectFile(BaseProject):
|
||||||
self._project_name = u(fh.readline().strip())
|
self._project_name = u(fh.readline().strip())
|
||||||
self._project_branch = u(fh.readline().strip())
|
self._project_branch = u(fh.readline().strip())
|
||||||
except:
|
except:
|
||||||
log.traceback()
|
log.traceback('warn')
|
||||||
except IOError: # pragma: nocover
|
except IOError: # pragma: nocover
|
||||||
log.traceback()
|
log.traceback('warn')
|
||||||
|
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -57,7 +57,7 @@ class SessionCache(object):
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
except: # pragma: nocover
|
except: # pragma: nocover
|
||||||
log.traceback()
|
log.traceback('debug')
|
||||||
|
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
|
@ -72,7 +72,7 @@ class SessionCache(object):
|
||||||
try:
|
try:
|
||||||
conn, c = self.connect()
|
conn, c = self.connect()
|
||||||
except:
|
except:
|
||||||
log.traceback()
|
log.traceback('debug')
|
||||||
return requests.session()
|
return requests.session()
|
||||||
|
|
||||||
session = None
|
session = None
|
||||||
|
@ -83,12 +83,12 @@ class SessionCache(object):
|
||||||
if row is not None:
|
if row is not None:
|
||||||
session = pickle.loads(row[0])
|
session = pickle.loads(row[0])
|
||||||
except: # pragma: nocover
|
except: # pragma: nocover
|
||||||
log.traceback()
|
log.traceback('debug')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
conn.close()
|
conn.close()
|
||||||
except: # pragma: nocover
|
except: # pragma: nocover
|
||||||
log.traceback()
|
log.traceback('debug')
|
||||||
|
|
||||||
return session if session is not None else requests.session()
|
return session if session is not None else requests.session()
|
||||||
|
|
||||||
|
@ -105,4 +105,4 @@ class SessionCache(object):
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
except:
|
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:
|
with open(file_name, 'r', encoding=sys.getfilesystemencoding()) as fh:
|
||||||
text = fh.read(512000)
|
text = fh.read(512000)
|
||||||
except:
|
except:
|
||||||
log.traceback()
|
log.traceback('debug')
|
||||||
return text
|
return text
|
||||||
|
|
Loading…
Reference in a new issue