logging --- Python 的日誌記錄工具

原始碼:Lib/logging/__init__.py


這個模組定義了函式與類別 (class),為應用程式和函式庫實作彈性的日誌管理系統。

由標準函式庫模組提供的日誌記錄 API 的主要好處是,所有的 Python 模組都能參與日誌記錄,因此你的應用程式日誌可以包含你自己的訊息,並與來自第三方模組的訊息整合在一起。

Here's a simple example of idiomatic usage:

# myapp.py
import logging
import mylib
logger = logging.getLogger(__name__)

def main():
    logging.basicConfig(filename='myapp.log', level=logging.