twisted.logger._json
module documentationtwisted.logger
View Source
Tools for saving and loading log events in a structured format.
Function | failureAsJSON | Convert a failure to a JSON-serializable data structure. |
Function | asBytes | No summary |
Function | failureFromJSON | Load a Failure from a
dictionary deserialized from JSON. |
Function | objectLoadHook | Dictionary-to-object-translation hook for certain value types used within the logging system. |
Function | objectSaveHook | Object-to-serializable hook for certain value types used within the logging system. |
Convert a failure to a JSON-serializable data structure.
Parameters | failure | A failure to serialize. (type: Failure ) |
Returns | a mapping of strings to ... stuff, mostly reminiscent of Failure.__getstate__ (type: dict ) |
On Python 2, we really need native strings in a variety of places; attribute names will sort of work in a __dict__, but they're subtly wrong; however, printing tracebacks relies on I/O to containers that only support bytes. This function converts _all_ native strings within a JSON-deserialized object to bytes.
Parameters | obj | A object to convert to bytes. (type: object ) |
Returns | A string of UTF-8 bytes. (type: bytes ) |
Object-to-serializable hook for certain value types used within the logging system.
Parameters | pythonObject | Any object. (type: object ) |
Returns | If the object is one of the special types the logging system supports, a specially-formatted dictionary; otherwise, a marker dictionary indicating that it could not be serialized. | |
See Also | the default parameter to json.dump |