smartinspectpython.sipatternparser
Capable of parsing and expanding a pattern string as used in the SITextProtocol and SITextFormatter classes.
The SIPatternParser class is capable of creating a text representation of a SILogEntry object (see Expand). The string representation can be influenced by setting a pattern string. Please see the Pattern property for a description.
Threadsafety:
This class is not guaranteed to be thread-safe.
Gets the Indent property value.
Indicates if the Expand method 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 string for this SIPatternParser object.
The pattern string influences the way a text representation of a SILogEntry object is created. A pattern string consists of a list of so called variable and literal tokens. When a string representation of a SILogEntry object is created, the variables are replaced with the actual values of the SILogEntry object.
Variables have a unique name, are surrounded with '%' characters and can have an optional options string enclosed in curly braces like this: %name{options}%.
You can also specify the minimum width of a value like this: %name,width%. Width must be a valid positive or negative integer. If the width is greater than 0, formatted values will be right-aligned. If the width is less than 0, they will be left-aligned.
The following table lists the available variables together with the corresponding Log Entry property.
Variable | Corresponding Property |
---|---|
%appname% | LogEntry.AppName |
%color% | LogEntry.ColorBG |
%hostname% | LogEntry.HostName |
%level% | Packet.Level |
%logentrytype% | LogEntry.LogEntryType |
%process% | LogEntry.ProcessId |
%session% | LogEntry.SessionName |
%thread% | LogEntry.ThreadId |
%timestamp% | LogEntry.Timestamp |
%title% | LogEntry.Title |
%viewerid% | LogEntry.ViewerId |
For the time-stamp token, you can use the options string to pass a custom date/time format string. This can look as follows: %timestamp{HH:mm:ss.fff}%
The format string must be a valid Python DateTime format string. The default format string used by the time-stamp token is "yyyy-MM-dd HH:mm:ss.fff".
Literals are preserved as specified in the pattern string. When a specified variable is unknown, it is handled as literal.
Examples:
"[%timestamp%] %level,8%: %title%"
"[%timestamp%] %session%: %title% (Level: %level%)"
Creates a text representation of a Log Entry by applying a user-specified Pattern string.
Arguments:
- logEntry (LogEntry): The Log Entry whose text representation should be computed by applying the current Pattern string. All recognized variables in the pattern string are replaced with the actual values of this Log Entry.
Returns:
The text representation for the supplied Log Entry object.