Giter Club home page Giter Club logo

Comments (7)

oprypin avatar oprypin commented on June 15, 2024 1

Using arguments instead of f-strings might still be valid, but last I checked it's not really viable to solve. Let me look again

from mkdocs.

oprypin avatar oprypin commented on June 15, 2024 1

I think this is the relevant documentation. Looking
https://docs.python.org/3/howto/logging-cookbook.html#formatting-styles

from mkdocs.

oprypin avatar oprypin commented on June 15, 2024 1

Yes so there are some super complicated solutions to make other formatting styles work, but this part is unchangeable about the log methods:

  • They accept only positional arguments. extra is for something else
  • They are hardcoded to use %s formatting.

So these two are pretty much the only reasonable options:

log.info("see %s", stuff)
log.info(f"see {stuff}")

I settled on one of them. Yes it has some performance disadvantages but big advantages in development.

from mkdocs.

oprypin avatar oprypin commented on June 15, 2024

Expected behaviour

Expected behavior for which piece of code?

& I think you're confusing something about the extra parameter. Have you tried using it outside of mkdocs? I'm pretty sure it won't work like that either

from mkdocs.

mondeja avatar mondeja commented on June 15, 2024

& I think you're confusing something about the extra parameter. Have you tried using it outside of mkdocs? I'm pretty sure it won't work like that either

Oops, is tightly binded to the formatting scheme, right? Sorry for the noise, closing this...

from mkdocs.

oprypin avatar oprypin commented on June 15, 2024

extra is for parameters that might be appropriate for every log message. The example shows user_id - it's a good example, because for a website a user id may indeed be present in almost every log. Then the logging configuration can choose to either print the user id somehow at the beginning in every message, or not print it.

from mkdocs.

mondeja avatar mondeja commented on June 15, 2024

Thanks for the detailed explanation! πŸ‘πŸΌ

from mkdocs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.