Improve debug logging to track prefixes