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.
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:
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:
logging.getLogger()to obtain pylance's logger;