Delgan / loguru

Python logging made (stupidly) simple
MIT License
18.69k stars 682 forks source link

Support printf-style formatting? #1151

Open NiklasRosenstein opened 2 weeks ago

NiklasRosenstein commented 2 weeks ago

I'm looking into migrating an existing project from Python's built-in logging facilities to loguru. The code base uses printf-style formatting quite extensively, e.g.

logger.info("Loading project %s", project.name)

Unfortunately loguru doesn't seem to be plug&play in this situation, unless I'm missing something. Is there a way to have loguru support percent-style formatting?

AlTosterino commented 2 weeks ago

Hey, did you check: https://loguru.readthedocs.io/en/stable/resources/migration.html#replacing-style-formatting-of-messages?

NiklasRosenstein commented 2 weeks ago

Sorry about that, I did not manage to find this page 👉 👈 . Thank you, I'll check this out next week.

Delgan commented 2 weeks ago

Hi.

Is there a way to have loguru support percent-style formatting?

Not really, you'll have to replace %s with {} in your logs.

See also https://github.com/Delgan/loguru/issues/991.