smartinspectpython.sitextformatter
Responsible for creating a text representation of a packet and writing it to a stream.
This class creates a text representation of a packet and writes it to a stream. The representation can be influenced with the Pattern property. The Compile method preprocesses a packet and computes the required size of the packet. The Write method writes the preprocessed packet to the supplied stream.
Threadsafety:
This class is not guaranteed to be thread-safe.
Gets the Indent property value.
Indicates if this formatter should automatically intend log packets like in the Views of the SmartInspect Console.
Log Entry packets of type EnterMethod increase the indentation and packets of type LeaveMethod decrease it.
Gets the Pattern property value.
Represents the pattern used to create a text representation of a packet.
For detailed information of how a pattern string can look like, please have a look at the documentation of the SIPatternParser class, especially the SIPatternParser.Pattern property.
Overridden. Preprocesses (or compiles) a packet and returns the required size for the compiled result.
Arguments:
- packet (SIPacket): The packet to compile.
Returns:
The size for the compiled result.
This method creates a text representation of the supplied packet and computes the required size. The resulting representation can be influenced with the Pattern property. To write a compiled packet, call the Write method. Please note that this method only supports Log Entry objects and ignores any other packet. This means, for packets other than Log Entry, this method always returns 0.
Overridden. Writes a previously compiled packet to the supplied stream.
Arguments:
- stream (BytesIO): The stream to write the packet to.
Raises:
- IOException: An I/O error occurred while trying to write the compiled packet.
This method writes the previously computed text representation of a packet (see Compile) to the supplied stream object. If the return value of the Compile method was 0, nothing is written.