RsSmbv Logger
Check the usage in the Getting Started chapter here.
- class ScpiLogger[source]
Base class for SCPI logging
- mode
Sets the logging ON or OFF. Additionally, you can set the logging ON only for errors. Possible values:
LoggingMode.Off - logging is switched OFF
LoggingMode.On - logging is switched ON
LoggingMode.Errors - logging is switched ON, but only for error entries
LoggingMode.Default - sets the logging to default - the value you have set with logger.default_mode
- start() None [source]
Starts the logging with the last defined LoggingMode. Default is LoggingMode.On
- default_mode
Sets / returns the default logging mode. You can recall the default mode by calling the ‘logger.mode = LoggingMode.Default’.
- device_name: str
Use this property to change the resource name in the log from the default Resource Name (e.g. TCPIP::192.168.2.101::INSTR) to another name e.g. ‘MySigGen1’.
- set_logging_target(target, console_log: Optional[bool] = None, udp_log: Optional[bool] = None) None [source]
Sets logging target - the target must implement write() and flush(). You can optionally set the console and UDP logging ON or OFF. This method switches the logging target global OFF.
- get_logging_target()[source]
Based on the global_mode, it returns the logging target: either the local or the global one.
- set_logging_target_global(console_log: Optional[bool] = None, udp_log: Optional[bool] = None) None [source]
Sets logging target to global. The global target must be defined. You can optionally set the console and UDP logging ON or OFF.
- log_to_console
Returns logging to console status.
- log_to_udp
Returns logging to UDP status.
- log_to_console_and_udp
Returns true, if both logging to UDP and console in are True.
- info_raw(log_entry: str, add_new_line: bool = True) None [source]
Method for logging the raw string without any formatting.
- info(start_time: datetime.datetime, end_time: datetime.datetime, log_string_info: str, log_string: str, cmd: Optional[str] = None) None [source]
Method for logging one info entry. For binary log_string, use the info_bin()
- error(start_time: datetime.datetime, end_time: datetime.datetime, log_string_info: str, log_string: str, cmd: Optional[str] = None) None [source]
Method for logging one error entry.
- set_relative_timestamp(timestamp: datetime.datetime) None [source]
If set, the further timestamps will be relative to the entered time.
- get_relative_timestamp() datetime.datetime [source]
Based on the global_mode, it returns the relative timestamp: either the local or the global one.
- clear_relative_timestamp() None [source]
Clears the reference time, and the further logging continues with absolute times.
- sync_from(source: RsSmbv.Internal.ScpiLogger.ScpiLogger) None [source]
Synchronises this Logger with the source logger.
- log_status_check_ok
Sets / returns the current status of status checking OK. If True (default), the log contains logging of the status checking ‘Status check: OK’. If False, the ‘Status check: OK’ is skipped - the log is more compact. Errors will still be logged.
- clear_cached_entries() None [source]
Clears potential cached log entries. Cached log entries are generated when the Logging is ON, but no target has been defined yet.
- set_format_string(value: str, line_divider: str = '\n') None [source]
Sets new format string and line divider. If you just want to set the line divider, set the format string value=None The original format string is:
PAD_LEFT12(%START_TIME%) PAD_LEFT25(%DEVICE_NAME%) PAD_LEFT12(%DURATION%) %LOG_STRING_INFO%: %LOG_STRING%
Additional variables to use:
%SCPI_COMMAND%
.
- restore_format_string() None [source]
Restores the original format string and the line divider to LF
- abbreviated_max_len_ascii: int
Defines the maximum length of one ASCII log entry. Default value is 200 characters.
- abbreviated_max_len_bin: int
Defines the maximum length of one Binary log entry. Default value is 2048 bytes.
- abbreviated_max_len_list: int
Defines the maximum length of one list entry. Default value is 100 elements.
- bin_line_block_size: int
Defines number of bytes to display in one line. Default value is 16 bytes.
- udp_port
Returns udp logging port.
- target_auto_flushing
Returns status of the auto-flushing for the logging target.
- log_info_replacer: RsSmbv.Internal.ScpiLogger.LogInfoReplacer
Replacer for Log Info Strings.
- class LogInfoReplacer[source]
Replacer, that takes the SCPI Logger Log Info and customizes its value.
Create the new LogInfoReplacer either with empty replacer dictionaries, or the ones from another LogInfoReplacer.
- set_full_replacer(repl_dict: Dict[str, str]) None [source]
Sets the full-replacer dictionary. This replacer searches the dictionary (case-sensitive) for the key that equals the LogInfoString, and replaces the whole info string with the string value associated with that key.
- put_full_replacer_item(match: str, replace: str) None [source]
Sets/replaces one item in the full replacer.
- set_regex_sr_replacer(repl_dict: Dict[re.Pattern, str]) None [source]
Sets the regex search&replace replacer dictionary. The replacer uses the re.sub() method of each key and replaces the matched substring with the string value associated with that key.
- put_regex_sr_replacer_item(search: re.Pattern, replace: str) re.Pattern [source]
Sets/replaces one item in the regex replacer. The key can be either a regex pattern, or a string. In case of the string, the key is compiled to a regex pattern, before it is put into the replacing dictionary. Returns the resulting search regex pattern.