RsInstrument.logger

Check the usage in the Getting Started chapter Logging.

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

stop() None[source]

Stops the logging. This is the same as: mode = LoggingMode.Off

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.

Data Type:

LoggingMode

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: bool = None, udp_log: 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: bool = None, udp_log: 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, end_time: datetime, log_string_info: str, log_string: str) None[source]

Method for logging one info entry. For binary log_string, use the info_bin()

error(start_time: datetime, end_time: datetime, log_string_info: str, log_string: str) None[source]

Method for logging one error entry.

set_relative_timestamp(timestamp: datetime) None[source]

If set, the further timestamps will be relative to the entered time.

set_relative_timestamp_now() None[source]

Sets the relative timestamp to the current time.

get_relative_timestamp() 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.

flush() None[source]

Flush all the entries.

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%

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.