upgrade wakatime cli to v4.0.12
This commit is contained in:
parent
f2f14207f5
commit
71ce25a326
3 changed files with 21 additions and 16 deletions
|
@ -1,7 +1,7 @@
|
||||||
__title__ = 'wakatime'
|
__title__ = 'wakatime'
|
||||||
__description__ = 'Common interface to the WakaTime api.'
|
__description__ = 'Common interface to the WakaTime api.'
|
||||||
__url__ = 'https://github.com/wakatime/wakatime'
|
__url__ = 'https://github.com/wakatime/wakatime'
|
||||||
__version_info__ = ('4', '0', '11')
|
__version_info__ = ('4', '0', '12')
|
||||||
__version__ = '.'.join(__version_info__)
|
__version__ = '.'.join(__version_info__)
|
||||||
__author__ = 'Alan Hamlett'
|
__author__ = 'Alan Hamlett'
|
||||||
__author_email__ = 'alan@wakatime.com'
|
__author_email__ = 'alan@wakatime.com'
|
||||||
|
|
|
@ -157,8 +157,10 @@ def parseArguments(argv):
|
||||||
parser.add_argument('--proxy', dest='proxy',
|
parser.add_argument('--proxy', dest='proxy',
|
||||||
help='optional https proxy url; for example: '+
|
help='optional https proxy url; for example: '+
|
||||||
'https://user:pass@localhost:8080')
|
'https://user:pass@localhost:8080')
|
||||||
parser.add_argument('--project', dest='project_name',
|
parser.add_argument('--project', dest='project',
|
||||||
help='optional project name; auto-discovered project takes priority')
|
help='optional project name')
|
||||||
|
parser.add_argument('--alternate-project', dest='alternate_project',
|
||||||
|
help='optional alternate project name; auto-discovered project takes priority')
|
||||||
parser.add_argument('--disableoffline', dest='offline',
|
parser.add_argument('--disableoffline', dest='offline',
|
||||||
action='store_false',
|
action='store_false',
|
||||||
help='disables offline time logging instead of queuing logged time')
|
help='disables offline time logging instead of queuing logged time')
|
||||||
|
@ -444,10 +446,13 @@ def main(argv=None):
|
||||||
if not args.notfile:
|
if not args.notfile:
|
||||||
project = find_project(args.targetFile, configs=configs)
|
project = find_project(args.targetFile, configs=configs)
|
||||||
branch = None
|
branch = None
|
||||||
project_name = args.project_name
|
project_name = args.project
|
||||||
if project:
|
if project:
|
||||||
branch = project.branch()
|
branch = project.branch()
|
||||||
|
if not project_name:
|
||||||
project_name = project.name()
|
project_name = project.name()
|
||||||
|
if not project_name:
|
||||||
|
project_name = args.alternate_project
|
||||||
|
|
||||||
if send_heartbeat(
|
if send_heartbeat(
|
||||||
project=project_name,
|
project=project_name,
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
:license: BSD, see LICENSE for more details.
|
:license: BSD, see LICENSE for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import inspect
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
@ -38,33 +37,32 @@ class CustomEncoder(json.JSONEncoder):
|
||||||
|
|
||||||
class JsonFormatter(logging.Formatter):
|
class JsonFormatter(logging.Formatter):
|
||||||
|
|
||||||
def setup(self, timestamp, isWrite, targetFile, version, plugin):
|
def setup(self, timestamp, isWrite, targetFile, version, plugin, verbose):
|
||||||
self.timestamp = timestamp
|
self.timestamp = timestamp
|
||||||
self.isWrite = isWrite
|
self.isWrite = isWrite
|
||||||
self.targetFile = targetFile
|
self.targetFile = targetFile
|
||||||
self.version = version
|
self.version = version
|
||||||
self.plugin = plugin
|
self.plugin = plugin
|
||||||
|
self.verbose = verbose
|
||||||
|
|
||||||
def format(self, record):
|
def format(self, record):
|
||||||
data = OrderedDict([
|
data = OrderedDict([
|
||||||
('now', self.formatTime(record, self.datefmt)),
|
('now', self.formatTime(record, self.datefmt)),
|
||||||
])
|
])
|
||||||
try:
|
|
||||||
data['package'] = inspect.stack()[9][0].f_globals.get('__package__')
|
|
||||||
data['lineno'] = inspect.stack()[9][2]
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
data['version'] = self.version
|
data['version'] = self.version
|
||||||
data['plugin'] = self.plugin
|
data['plugin'] = self.plugin
|
||||||
data['time'] = self.timestamp
|
data['time'] = self.timestamp
|
||||||
|
if self.verbose:
|
||||||
|
data['caller'] = record.pathname
|
||||||
|
data['lineno'] = record.lineno
|
||||||
data['isWrite'] = self.isWrite
|
data['isWrite'] = self.isWrite
|
||||||
data['file'] = self.targetFile
|
data['file'] = self.targetFile
|
||||||
|
if not self.isWrite:
|
||||||
|
del data['isWrite']
|
||||||
data['level'] = record.levelname
|
data['level'] = record.levelname
|
||||||
data['message'] = record.msg
|
data['message'] = record.msg
|
||||||
if not self.plugin:
|
if not self.plugin:
|
||||||
del data['plugin']
|
del data['plugin']
|
||||||
if not self.isWrite:
|
|
||||||
del data['isWrite']
|
|
||||||
return CustomEncoder().encode(data)
|
return CustomEncoder().encode(data)
|
||||||
|
|
||||||
def formatException(self, exc_info):
|
def formatException(self, exc_info):
|
||||||
|
@ -90,6 +88,7 @@ def setup_logging(args, version):
|
||||||
targetFile=args.targetFile,
|
targetFile=args.targetFile,
|
||||||
version=version,
|
version=version,
|
||||||
plugin=args.plugin,
|
plugin=args.plugin,
|
||||||
|
verbose=args.verbose,
|
||||||
)
|
)
|
||||||
logger.handlers[0].setFormatter(formatter)
|
logger.handlers[0].setFormatter(formatter)
|
||||||
return logger
|
return logger
|
||||||
|
@ -104,6 +103,7 @@ def setup_logging(args, version):
|
||||||
targetFile=args.targetFile,
|
targetFile=args.targetFile,
|
||||||
version=version,
|
version=version,
|
||||||
plugin=args.plugin,
|
plugin=args.plugin,
|
||||||
|
verbose=args.verbose,
|
||||||
)
|
)
|
||||||
handler.setFormatter(formatter)
|
handler.setFormatter(formatter)
|
||||||
logger.addHandler(handler)
|
logger.addHandler(handler)
|
||||||
|
|
Loading…
Reference in a new issue