get_module_logger
时间: 2023-11-26 09:04:15 浏览: 71
`get_module_logger` is a function provided by the Python `logging` module that returns a logger object with the specified name. It allows you to create a logger object for a specific module or package, which can then be used to log messages with various severity levels (e.g. debug, info, warning, error, critical).
Here's an example of how to use `get_module_logger`:
```python
import logging
# create a logger object for the current module
logger = logging.getLogger(__name__)
# log a message with INFO level
logger.info('This is an info message')
# log a message with ERROR level
logger.error('This is an error message')
```
In this example, `__name__` represents the name of the current module, which is passed to `get_module_logger` to create a logger object. The logger object is then used to log messages with different severity levels. By default, the messages are output to the console, but you can configure the logging system to write messages to a file or send them to a remote server.
阅读全文