SG-43417 Isolate publisher log handler per dialog instance#218
SG-43417 Isolate publisher log handler per dialog instance#218chenm1adsk wants to merge 1 commit into
Conversation
Issue or Context:
When two publisher dialogs are open simultaneously in the same Python
process, log records emitted by hooks in Dialog A also show up in
Dialog B's progress widget. Each dialog's progress tree gets polluted
with the other dialog's log lines.
Root Cause:
`PublishLogWrapper.__init__` calls `logging.getLogger("<bundle>.hook")`
with the same name for every instance. `logging.getLogger(name)` is
cached by name and returns the same Logger object, so each dialog's
`addHandler(self._handler)` accumulates on the shared logger. A log
record then dispatches to every attached handler, including the other
dialog's.
Fix Applied:
Append a `uuid.uuid4().hex` suffix to the logger name in
`PublishLogWrapper.__init__` so each instance gets its own Logger
object. The prefix `<bundle>.hook.` is preserved for any consumers
that filter by prefix. `propagate = False` is already set, so the
unique child logger does not bubble up the hierarchy.
There was a problem hiding this comment.
Pull request overview
Fixes log handler cross-talk between simultaneously open publisher dialogs. Previously, PublishLogWrapper.__init__ called logging.getLogger("<bundle>.hook") with the same name for every instance, so each dialog's handler accumulated on the same shared Logger, and records emitted in one dialog were dispatched to handlers attached by the other. The fix appends a uuid.uuid4().hex suffix to the logger name so each instance gets a unique Logger.
Changes:
- Import
uuidinpublish_logging.py. - Append a per-instance
uuid.uuid4().hexsuffix to the hook logger name to isolate handlers per dialog instance.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| unique_id = uuid.uuid4().hex | ||
| full_log_path = "%s.hook.%s" % (self._bundle.logger.name, unique_id) |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #218 +/- ##
==========================================
- Coverage 40.81% 40.79% -0.02%
==========================================
Files 63 63
Lines 5109 5111 +2
==========================================
Hits 2085 2085
- Misses 3024 3026 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
Fix log handler cross-talk between simultaneously open publisher dialogs.
When two publisher dialogs are open in the same Python process, log records emitted by hooks in Dialog A also show up in Dialog B's progress widget. Each dialog's progress tree gets polluted with the other dialog's log lines.
Root cause
PublishLogWrapper.__init__callslogging.getLogger("<bundle>.hook")with the same name for every instance.logging.getLogger(name)is cached by name and returns the sameLoggerobject, so each dialog'saddHandler(self._handler)accumulates on the shared logger. A log record then dispatches to every attached handler, including the other dialog's.Fix
Append a
uuid.uuid4().hexsuffix to the logger name inPublishLogWrapper.__init__so each instance gets its ownLoggerobject.<bundle>.hook.is preserved for any consumers that filter by prefix.propagate = Falseis already set, so the unique child logger does not bubble up the hierarchy.uuidis stdlib, no new dependency.Files
python/tk_multi_publish2/progress/publish_logging.pyTest plan