upgrade wakatime cli to v4.0.14

This commit is contained in:
Alan Hamlett 2015-05-31 17:50:47 -07:00
parent a05fa9411f
commit 201aa07bc4
3 changed files with 29 additions and 14 deletions

View file

@ -1,7 +1,7 @@
__title__ = 'wakatime'
__description__ = 'Common interface to the WakaTime api.'
__url__ = 'https://github.com/wakatime/wakatime'
__version_info__ = ('4', '0', '13')
__version_info__ = ('4', '0', '14')
__version__ = '.'.join(__version_info__)
__author__ = 'Alan Hamlett'
__author_email__ = 'alan@wakatime.com'

View file

@ -455,15 +455,11 @@ def main(argv=None):
project_name = args.alternate_project
kwargs = vars(args)
if 'project' in kwargs:
del kwargs['project']
kwargs['project'] = project_name
kwargs['branch'] = branch
kwargs['stats'] = stats
if send_heartbeat(
project=project_name,
branch=branch,
stats=stats,
**kwargs
):
if send_heartbeat(**kwargs):
queue = Queue()
while True:
heartbeat = queue.pop()

View file

@ -37,15 +37,17 @@ class CustomEncoder(json.JSONEncoder):
class JsonFormatter(logging.Formatter):
def setup(self, timestamp, isWrite, targetFile, version, plugin, verbose):
def setup(self, timestamp, isWrite, targetFile, version, plugin, verbose,
warnings=False):
self.timestamp = timestamp
self.isWrite = isWrite
self.targetFile = targetFile
self.version = version
self.plugin = plugin
self.verbose = verbose
self.warnings = warnings
def format(self, record):
def format(self, record, *args):
data = OrderedDict([
('now', self.formatTime(record, self.datefmt)),
])
@ -60,7 +62,7 @@ class JsonFormatter(logging.Formatter):
if not self.isWrite:
del data['isWrite']
data['level'] = record.levelname
data['message'] = record.msg
data['message'] = record.getMessage() if self.warnings else record.msg
if not self.plugin:
del data['plugin']
return CustomEncoder().encode(data)
@ -77,7 +79,6 @@ def set_log_level(logger, args):
def setup_logging(args, version):
logging.captureWarnings(True)
logger = logging.getLogger('WakaTime')
set_log_level(logger, args)
if len(logger.handlers) > 0:
@ -107,5 +108,23 @@ def setup_logging(args, version):
)
handler.setFormatter(formatter)
logger.addHandler(handler)
logging.getLogger('py.warnings').addHandler(handler)
warnings_formatter = JsonFormatter(datefmt='%Y/%m/%d %H:%M:%S %z')
warnings_formatter.setup(
timestamp=args.timestamp,
isWrite=args.isWrite,
targetFile=args.targetFile,
version=version,
plugin=args.plugin,
verbose=args.verbose,
warnings=True,
)
warnings_handler = logging.FileHandler(os.path.expanduser(logfile))
warnings_handler.setFormatter(warnings_formatter)
logging.getLogger('py.warnings').addHandler(warnings_handler)
try:
logging.captureWarnings(True)
except AttributeError:
pass # Python >= 2.7 is needed to capture warnings
return logger