Skip to content

Commit

Permalink
Fix logging interpolation
Browse files Browse the repository at this point in the history
Previously, message and args would each get interpolated separately,
with a result like

   wrote python info of %s at (PosixPath('/usr/bin/python3.12'),
   PosixPath('/home/...f265.json')) [DEBUG via_disk_folder:153]

Now, interpolate the message (which has its own formatting placeholder)
first, then the args; the result is more like

   wrote python info of /usr/bin/python3.12 at /home/...f265.json
   [DEBUG via_disk_folder:153]
  • Loading branch information
tipabu committed Feb 24, 2025
1 parent eaef9bb commit d757d00
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/virtualenv/app_data/via_disk_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def read(self):
except Exception: # noqa: BLE001, S110
pass
else:
LOGGER.debug("got %s from %s", self.msg, self.msg_args)
LOGGER.debug(f"got {self.msg} from %s", *self.msg_args)
return data
if bad_format:
with suppress(OSError): # reading and writing on the same file may cause race on multiple processes
Expand All @@ -139,7 +139,7 @@ def read(self):

def remove(self):
self.file.unlink()
LOGGER.debug("removed %s at %s", self.msg, self.msg_args)
LOGGER.debug(f"removed {self.msg} at %s", *self.msg_args)

@contextmanager
def locked(self):
Expand All @@ -150,7 +150,7 @@ def write(self, content):
folder = self.file.parent
folder.mkdir(parents=True, exist_ok=True)
self.file.write_text(json.dumps(content, sort_keys=True, indent=2), encoding="utf-8")
LOGGER.debug("wrote %s at %s", self.msg, self.msg_args)
LOGGER.debug(f"wrote {self.msg} at %s", *self.msg_args)


class PyInfoStoreDisk(JSONStoreDisk):
Expand Down

0 comments on commit d757d00

Please sign in to comment.