log_json¶
The log_json
is a function that given a dictionary, returns a
json structure.
This helps that logs can be parsed and processed by external tools.
The arguments are:
log_json(log, indent=False)
log: | a python dictionary |
---|---|
indent: | returns the json structured indented (more human readable) |
Note
If indent is a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0, or negative, will only insert newlines. None (the default) selects the most compact representation.
See also
Example¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | from zunzuncito import tools
class APIResource(object):
def dispatch(self, request, response):
request.log.debug(tools.log_json({
'API': request.version,
'Method': request.method,
'URI': request.URI,
'vroot': request.vroot
}, True))
""" your code goes here """
|
See also
A great amount of time has been spent creating, crafting and maintaining this software, please consider donating.
Donating helps ensure continued support, development and availability.
comments powered by Disqus