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 — Provide method to get list of logging level names · Issue #88024 · python/cpython

Provide method to get list of logging level names #88024

New issue
Copy link
New issue
Copy link
Closed
Closed
Provide method to get list of logging level names#88024
Copy link
Assignees
vsajip
Labels
3.11only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

Description

andylowry
mannequin
opened on Apr 15, 2021
Issue body actions
BPO 43858
Nosy @rhettinger, @vsajip, @ericvsmith, @miss-islington, @akulakov, @shreyanavigyan, @andylowry
PRs
  • bpo-43858: Add logging.getLevelNamesMapping() #26459
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/vsajip'
    closed_at = <Date 2021-06-03.08:59:30.308>
    created_at = <Date 2021-04-15.17:46:57.939>
    labels = ['type-feature', 'library', '3.11']
    title = 'Provide method to get list of logging level names'
    updated_at = <Date 2021-06-03.08:59:30.303>
    user = 'https://github.com/andylowry'

    bugs.python.org fields:

    activity = <Date 2021-06-03.08:59:30.303>
    actor = 'vinay.sajip'
    assignee = 'vinay.sajip'
    closed = True
    closed_date = <Date 2021-06-03.08:59:30.308>
    closer = 'vinay.sajip'
    components = ['Library (Lib)']
    creation = <Date 2021-04-15.17:46:57.939>
    creator = 'andylowry'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 43858
    keywords = ['patch']
    message_count = 6.0
    messages = ['391145', '391147', '393833', '394764', '394765', '394989']
    nosy_count = 7.0
    nosy_names = ['rhettinger', 'vinay.sajip', 'eric.smith', 'miss-islington', 'andrei.avk', 'shreyanavigyan', 'andylowry']
    pr_nums = ['26459']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue43858'
    versions = ['Python 3.11']

    Activity

    1. andylowry commented on Apr 15, 2021

      @andylowry
      andylowrymannequin
      on Apr 15, 2021
      MannequinAuthor
      More actions

      It would be useful to have something like a getLevelNames method to return the current list of level names, ordered by priority.

      This currently appears to be available only by accessing a private member, like _levelToName or _nameToLevel.

      This functionality is useful, for example, in populating a choices list for an argparse option to allow a user to select a logging level when launching a program from a command line.

    2. andylowry
      added
      3.8 (EOL)end of lifeend of life
      stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
      on Apr 15, 2021
    3. shreyanavigyan commented on Apr 15, 2021

      @shreyanavigyan
      shreyanavigyanmannequin
      on Apr 15, 2021
      Mannequin
      More actions

      I agree with you. It would be nice to have a function to list or dictionary of level names. Moreover I suggest that there should be an argument to the function like format_level which can take in "dict:level_name" for returning a dictionary with the level as keys and name as values, "dict:name_level" for returning a dictionary with the name as keys and level as values or "list" for returning just the list of level names ordered by priority.

    4. akulakov commented on May 17, 2021

      @akulakov
      akulakov
      on May 17, 2021
      Contributor
      More actions

      I can add getLevelNamesDict() which would return a copy of _nameToLevel, which is currently

      _nameToLevel = {
          'CRITICAL': CRITICAL,
          'FATAL': FATAL,
          'ERROR': ERROR,
          'WARN': WARNING,
          'WARNING': WARNING,
          'INFO': INFO,
          'DEBUG': DEBUG,
          'NOTSET': NOTSET,
      }

      I think it may be best not to return a list of levels because it's not obvious that some of them are aliases, if the caller is responsible for making the list out of the dict, they will be able to decide how to deal with alias levels.

      If that sounds good I can make a PR..

    5. andylowry commented on May 30, 2021

      @andylowry
      andylowrymannequin
      on May 30, 2021
      MannequinAuthor
      More actions

      @andrei.avk Yes, that sounds just fine. Many thanks.

    6. rhettinger commented on May 30, 2021

      @rhettinger
      rhettinger
      on May 30, 2021
      Contributor
      More actions

      I can add getLevelNamesDict() which would return a copy of _nameToLevel

      That seem like the best approach.

    7. rhettinger
      assigned
      vsajip
      on May 30, 2021
    8. miss-islington commented on Jun 3, 2021

      @miss-islington
      miss-islington
      on Jun 3, 2021
      Contributor
      More actions

      New changeset 8b93f0e by andrei kulakov in branch 'main':
      bpo-43858: Add logging.getLevelNamesMapping() (GH-26459)
      8b93f0e

      Reacted by taylorpetty
    9. vsajip
      added
      3.11only security fixesonly security fixes
      and removed
      3.8 (EOL)end of lifeend of life
      on Jun 3, 2021
    10. vsajip
      closed this as completedon Jun 3, 2021
    11. vsajip
      added
      3.11only security fixesonly security fixes
      type-featureA feature request or enhancementA feature request or enhancement
      and removed
      3.8 (EOL)end of lifeend of life
      on Jun 3, 2021
    12. vsajip
      closed this as completedon Jun 3, 2021
    13. vsajip
      added
      type-featureA feature request or enhancementA feature request or enhancement
      on Jun 3, 2021
    14. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    • @vsajip
      vsajip

    Labels

    3.11only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

    Projects

    No projects

      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.