mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-12-01 01:25:07 +08:00
76 lines
1.3 KiB
Markdown
76 lines
1.3 KiB
Markdown
|
---
|
||
|
sidebar_position: 7
|
||
|
description: nonebot.log 模块
|
||
|
---
|
||
|
|
||
|
# nonebot.log
|
||
|
|
||
|
本模块定义了 NoneBot 的日志记录 Logger。
|
||
|
|
||
|
NoneBot 使用 [`loguru`][loguru] 来记录日志信息。
|
||
|
|
||
|
自定义 logger 请参考 [自定义日志](https://v2.nonebot.dev/docs/tutorial/custom-logger)
|
||
|
以及 [`loguru`][loguru] 文档。
|
||
|
|
||
|
[loguru]: https://github.com/Delgan/loguru
|
||
|
|
||
|
## _var_ `logger` {#logger}
|
||
|
|
||
|
- **类型:** Logger
|
||
|
|
||
|
- **说明**
|
||
|
|
||
|
NoneBot 日志记录器对象。
|
||
|
|
||
|
默认信息:
|
||
|
|
||
|
- 格式: `[%(asctime)s %(name)s] %(levelname)s: %(message)s`
|
||
|
- 等级: `INFO` ,根据 `config.log_level` 配置改变
|
||
|
- 输出: 输出至 stdout
|
||
|
|
||
|
- **用法**
|
||
|
|
||
|
```python
|
||
|
from nonebot.log import logger
|
||
|
```
|
||
|
|
||
|
## _var_ `default_format` {#default_format}
|
||
|
|
||
|
- **类型:** str
|
||
|
|
||
|
- **说明:** 默认日志格式
|
||
|
|
||
|
## _class_ `LoguruHandler(level=0)` {#LoguruHandler}
|
||
|
|
||
|
- **说明**
|
||
|
|
||
|
logging 与 loguru 之间的桥梁,将 logging 的日志转发到 loguru。
|
||
|
|
||
|
- **参数**
|
||
|
|
||
|
- `level`
|
||
|
|
||
|
### _method_ `emit(self, record)` {#LoguruHandler-emit}
|
||
|
|
||
|
- **参数**
|
||
|
|
||
|
- `record` (logging.LogRecord)
|
||
|
|
||
|
- **返回**
|
||
|
|
||
|
- Unknown
|
||
|
|
||
|
## _def_ `default_filter(record)` {#default_filter}
|
||
|
|
||
|
- **说明**
|
||
|
|
||
|
默认的日志过滤器,根据 `config.log_level` 配置改变日志等级。
|
||
|
|
||
|
- **参数**
|
||
|
|
||
|
- `record` (Record)
|
||
|
|
||
|
- **返回**
|
||
|
|
||
|
- Unknown
|