Skip to content

Pylance shoud use a sub-level logger of logging #3195

@yanghua

Description

@yanghua

Currently, I noticed that PyLance directly uses logging to record logs. So, when we need to modify the log level, we have to do it in the following way:

logging.basicConfig(level=logging.DEBUG)

The intention behind this is to achieve the goal by modifying the root logger of logging. However, this doesn't seem to be an optimal practice. The optimal practice should be to use the sublevel of logging to prevent changes to the log level from having out-of-scope impacts, like the fsspec's practice. Generally, in a typical Python project, multiple frameworks are usually used, and they may all use the logging modules. If we modify the log level of the root logger, the impact scope of this change may exceed expectations (or there may be side effects).
Therefore, my suggestion is to use the sub-logger and make the following changes:

  • Use logging.getLogger() to obtain pylance's logger;
  • Use APIs or environment variables to control the log level of the PyLance logger.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions