feat: add log_response_max_length option to truncate logged command responses#606
Open
DaPillah wants to merge 3 commits into
Open
feat: add log_response_max_length option to truncate logged command responses#606DaPillah wants to merge 3 commits into
DaPillah wants to merge 3 commits into
Conversation
Add a global log_response_max_length config option and a matching per-command argument on query(), query_binary(), and query_raw_binary() to cap how many characters of a command response are written to the logs. Defaults to None (no truncation), preserving existing behavior. Refs: tektronix#396
DaPillah
requested review from
amccann-Tek,
ldantek,
michaelwagoner,
nfelt14,
pradhansk,
tekperson and
v12ganesh
July 17, 2026 17:19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Some instrument commands (e.g. an oscilloscope's
CURVe?) can return responses of manymegabytes to gigabytes.
tm_deviceslogs each response in full, which can create huge logfiles that are impractical to open and can fill the disk.
This adds two ways to cap how much of a command response is written to the logs, as discussed
in the issue:
log_response_max_length(Optional[int], defaultNone) —truncates all logged responses to N characters. It follows the existing
log_*configconvention, so it is automatically forwarded to
configure_logging().log_response_max_lengthonquery(),query_binary(), andquery_raw_binary()— truncates the logged response for a single call.None(the default)defers to the global option; an integer overrides it (
0suppresses the response contents).When a response is truncated, the log entry keeps the start of the response and appends a clear
marker, e.g.:
The default (
None) disables truncation, so existing behavior is unchanged unless a user optsin. The full, untruncated response is always still returned to the caller. Only the log entry
is shortened.
Addresses #396
Types of changes
Checklist
Addresses #396