Skip to content

ngclient: Use %-style formatting in logging #1400

Description

@jku

(this is about code currently in experimental-client/ngclient branch, hopefully soon in develop)

We currently have some f-strings in logging:

                        msg = (
                            f"Adding child role {child_role_name}.\n",
                            "Not backtracking to other roles.",
                        )
                        logger.debug(msg)

Let's use %-style instead in logging (even if f-strings are great for other string formatting, see the google python style guide)

Activity

  1. changed the title [-]experimental client: Use %-style formatting in logging[/-] [+]ngclient: Use %-style formatting in logging[/+] on May 25, 2021
  2. added
    backlogIssues to address with priority for current development goals
    on May 26, 2021
  3. added this to the weeks24-25 milestone on Jun 9, 2021
  4. avelichka commented on Jun 9, 2021

    @avelichka
    Contributor

    I'd like to give it a try, please?

  5. trishankatdatadog commented on Jun 9, 2021

    @trishankatdatadog
    Contributor

    Curious: why does Google recommend % over f-strings? I think the latter is far more readable, no?

  6. jku commented on Jun 10, 2021

    @jku
    MemberAuthor

    I agree, it's just that f-strings get greedily evaluated before logger can check if they are needed: with %-style the logger can check if the string is needed (and usually it isn't) before building the string. Obviously 99% of our logging is nowhere near a critical path where this would matter ... but I'd still like to be able to log inside e.g. a download loop without thinking about it.

    The other reason would be that our linters complain :) We could of course modify our linter config (and document the style guide difference) but that feels like work too...

  7. trishankatdatadog commented on Jun 10, 2021

    @trishankatdatadog
    Contributor

    My 0.02 BTC is that we should keep developers not Google/linters/speedtests happy, but that's just me. I will let you guys decide 🙂

  8. modified the milestones: weeks26-27, Sprint 4 on Jul 7, 2021
  9. removed
    backlogIssues to address with priority for current development goals
    on Jul 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions