GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — logging module LogRecord can accept non-str msg but it's not documented · Issue #102873 · python/cpython

logging module LogRecord can accept non-str msg but it's not documented #102873

New issue
Copy link
New issue
Copy link
Closed
#102875
Closed
logging module LogRecord can accept non-str msg but it's not documented#102873
#102875
Copy link
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir

Description

@aminalaee
aminalaee
opened on Mar 21, 2023
Issue body actions

Documentation

In the documentation of the logging LogRecord it's mentioned that it accepts msg as str argument:
https://docs.python.org/3/library/logging.html#logging.LogRecord

But just below that it explains that in getMessage:

Returns the message for this LogRecord instance after merging any user-supplied arguments with the message. If the user-supplied message argument to the logging call is not a string, str() is called on it to convert it to a string. This allows use of user-defined classes as messages, whose str method can return the actual format string to be used.

So non-str messages are allowed, and also in LogRecord attributes it's mentioned that non-str messages work and are accepted:
https://docs.python.org/3/library/logging.html#logrecord-attributes

Initially started the discussion in python/typeshed#9914

Linked PRs

  • gh-102873: logging.LogRecord docs: improve description of msg parameter #102875
  • [3.11] gh-102873: logging.LogRecord docs: improve description of msg parameter (GH-102875) #103003
  • [3.10] gh-102873: logging.LogRecord docs: improve description of msg parameter (GH-102875) #103004

Activity

  1. aminalaee
    added
    docsDocumentation in the Doc dirDocumentation in the Doc dir
    on Mar 21, 2023
  2. aminalaee
    added a commit that references this issue on Mar 21, 2023

    pythongh-102873: Update logging LogRecord argument types

    6874794
  3. aminalaee commented on Mar 21, 2023

    @aminalaee
    aminalaee
    on Mar 21, 2023
    ContributorAuthor
    More actions

    cc @AlexWaygood

    Reacted by Alex Waygood
  4. aminalaee
    changed the title [-]logging module LogRecord can accept non-str msg but it's not reflected[/-] [+]logging module LogRecord can accept non-str msg but it's not documented[/+] on Mar 21, 2023
  5. AlexWaygood
    added this to Logging issues 🪵on Mar 21, 2023
  6. AlexWaygood
    moved this to In Progress in Logging issues 🪵on Mar 21, 2023
  7. arhadthedev commented on Mar 22, 2023

    @arhadthedev
    arhadthedev
    on Mar 22, 2023
    Member
    More actions

    @vsajip (as a logging expert)

  8. AlexWaygood
    closed this as completedin #102875on Mar 24, 2023
  9. github-project-automation
    moved this from In Progress to Done in Logging issues 🪵on Mar 24, 2023
  10. AlexWaygood
    added a commit that references this issue on Mar 24, 2023

    gh-102873: logging.LogRecord docs: improve description of `msg` param…

    f2e5a6e
  11. miss-islington
    added 4 commits that reference this issue on Mar 24, 2023

    pythongh-102873: logging.LogRecord docs: improve description of `msg`…

    fd3c8c2

    pythongh-102873: logging.LogRecord docs: improve description of `msg`…

    e39145f

    gh-102873: logging.LogRecord docs: improve description of `msg` param…

    cbffc3a

    gh-102873: logging.LogRecord docs: improve description of `msg` param…

    c834a4c
  12. AlexWaygood commented on Mar 24, 2023

    @AlexWaygood
    AlexWaygood
    on Mar 24, 2023
    Member
    More actions

    Thanks @aminalaee!

    Reacted by Amin Alaee
  13. Fidget-Spinner
    added a commit that references this issue on Mar 27, 2023

    pythongh-102873: logging.LogRecord docs: improve description of `msg`…

    a11fcbb
  14. warsaw
    added a commit that references this issue on Apr 11, 2023

    pythongh-102873: logging.LogRecord docs: improve description of `msg`…

    4e950aa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dirDocumentation in the Doc dir

    Projects

    • Logging issues 🪵
      Status
      Done
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.