Remove spaces from JSON output
This commit is contained in:
@ -81,8 +81,9 @@ class CSVlog(LOGlog):
|
||||
# JSON logging
|
||||
#
|
||||
class JSONlog(LOGlog):
|
||||
def __init__(self):
|
||||
def __init__(self, quoted=0):
|
||||
super().__init__()
|
||||
self.quoted = quoted
|
||||
|
||||
def make(self, dire="logs", basename="log-", ext="json"):
|
||||
return super().make(dire, basename, ext)
|
||||
@ -94,8 +95,10 @@ class JSONlog(LOGlog):
|
||||
super().header(str)
|
||||
|
||||
def write(self, data):
|
||||
# data['timestamp'] = time()
|
||||
super().write(json.dumps(data))
|
||||
if self.quoted:
|
||||
super().write("'" + json.dumps(data, separators=(',', ':')) + "'")
|
||||
else:
|
||||
super().write(json.dumps(data, separators=(',', ':')))
|
||||
|
||||
def read(self, ):
|
||||
return json.loads(super().read())
|
||||
|
||||
Reference in New Issue
Block a user