log all unknown exceptions to wakatime.log file

This commit is contained in:
Alan Hamlett 2015-10-23 00:14:41 -07:00
parent fdc2981e74
commit d389be2876

View file

@ -412,59 +412,62 @@ def execute(argv=None):
setup_logging(args, __version__) setup_logging(args, __version__)
exclude = should_exclude(args.entity, args.include, args.exclude) try:
if exclude is not False: exclude = should_exclude(args.entity, args.include, args.exclude)
log.debug(u('Skipping because matches exclude pattern: {pattern}').format( if exclude is not False:
pattern=u(exclude), log.debug(u('Skipping because matches exclude pattern: {pattern}').format(
)) pattern=u(exclude),
return 0 ))
return 0
if args.entity_type != 'file' or os.path.isfile(args.entity): if args.entity_type != 'file' or os.path.isfile(args.entity):
stats = get_file_stats(args.entity, entity_type=args.entity_type, stats = get_file_stats(args.entity, entity_type=args.entity_type,
lineno=args.lineno, cursorpos=args.cursorpos) lineno=args.lineno, cursorpos=args.cursorpos)
project = args.project or args.alternate_project project = args.project or args.alternate_project
branch = None branch = None
if args.entity_type == 'file': if args.entity_type == 'file':
project, branch = get_project_info(configs, args) project, branch = get_project_info(configs, args)
kwargs = vars(args) kwargs = vars(args)
kwargs['project'] = project kwargs['project'] = project
kwargs['branch'] = branch kwargs['branch'] = branch
kwargs['stats'] = stats kwargs['stats'] = stats
kwargs['hostname'] = args.hostname or socket.gethostname() kwargs['hostname'] = args.hostname or socket.gethostname()
kwargs['timeout'] = args.timeout kwargs['timeout'] = args.timeout
if send_heartbeat(**kwargs): if send_heartbeat(**kwargs):
queue = Queue() queue = Queue()
while True: while True:
heartbeat = queue.pop() heartbeat = queue.pop()
if heartbeat is None: if heartbeat is None:
break break
sent = send_heartbeat( sent = send_heartbeat(
project=heartbeat['project'], project=heartbeat['project'],
entity=heartbeat['entity'], entity=heartbeat['entity'],
timestamp=heartbeat['time'], timestamp=heartbeat['time'],
branch=heartbeat['branch'], branch=heartbeat['branch'],
hostname=kwargs['hostname'], hostname=kwargs['hostname'],
stats=json.loads(heartbeat['stats']), stats=json.loads(heartbeat['stats']),
key=args.key, key=args.key,
isWrite=heartbeat['is_write'], isWrite=heartbeat['is_write'],
plugin=heartbeat['plugin'], plugin=heartbeat['plugin'],
offline=args.offline, offline=args.offline,
hidefilenames=args.hidefilenames, hidefilenames=args.hidefilenames,
entity_type=heartbeat['type'], entity_type=heartbeat['type'],
proxy=args.proxy, proxy=args.proxy,
api_url=args.api_url, api_url=args.api_url,
timeout=args.timeout, timeout=args.timeout,
) )
if not sent: if not sent:
break break
return 0 # success return 0 # success
return 102 # api error return 102 # api error
else: else:
log.debug('File does not exist; ignoring this heartbeat.') log.debug('File does not exist; ignoring this heartbeat.')
return 0 return 0
except:
log.traceback()