mirror of
				https://github.com/nonebot/nonebot2.git
				synced 2025-11-04 00:46:43 +00:00 
			
		
		
		
	
		
			Some checks failed
		
		
	
	Code Coverage / Test Coverage (pydantic-v1, ubuntu-latest, 3.10) (push) Failing after 1m25s
				
			Code Coverage / Test Coverage (pydantic-v1, ubuntu-latest, 3.11) (push) Failing after 1m24s
				
			Code Coverage / Test Coverage (pydantic-v1, ubuntu-latest, 3.12) (push) Failing after 1m30s
				
			Code Coverage / Test Coverage (pydantic-v1, ubuntu-latest, 3.9) (push) Failing after 1m23s
				
			Code Coverage / Test Coverage (pydantic-v2, ubuntu-latest, 3.10) (push) Failing after 1m28s
				
			Code Coverage / Test Coverage (pydantic-v2, ubuntu-latest, 3.11) (push) Failing after 1m33s
				
			Code Coverage / Test Coverage (pydantic-v2, ubuntu-latest, 3.12) (push) Failing after 1m22s
				
			Code Coverage / Test Coverage (pydantic-v2, ubuntu-latest, 3.9) (push) Failing after 1m37s
				
			Pyright Lint / Pyright Lint (pydantic-v1) (push) Failing after 1m23s
				
			Pyright Lint / Pyright Lint (pydantic-v2) (push) Failing after 1m19s
				
			Ruff Lint / Ruff Lint (push) Successful in 27s
				
			Site Deploy / publish (push) Failing after 1m31s
				
			Code Coverage / Test Coverage (pydantic-v1, macos-latest, 3.10) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v1, macos-latest, 3.11) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v1, macos-latest, 3.12) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v1, macos-latest, 3.9) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v1, windows-latest, 3.10) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v1, windows-latest, 3.11) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v1, windows-latest, 3.12) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v1, windows-latest, 3.9) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v2, macos-latest, 3.10) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v2, macos-latest, 3.11) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v2, macos-latest, 3.12) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v2, macos-latest, 3.9) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v2, windows-latest, 3.10) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v2, windows-latest, 3.11) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v2, windows-latest, 3.12) (push) Has been cancelled
				
			Code Coverage / Test Coverage (pydantic-v2, windows-latest, 3.9) (push) Has been cancelled
				
			
		
			
				
	
	
		
			74 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			74 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
---
 | 
						|
mdx:
 | 
						|
  format: md
 | 
						|
sidebar_position: 7
 | 
						|
description: nonebot.log 模块
 | 
						|
---
 | 
						|
 | 
						|
# nonebot.log
 | 
						|
 | 
						|
本模块定义了 NoneBot 的日志记录 Logger。
 | 
						|
 | 
						|
NoneBot 使用 [`loguru`][loguru] 来记录日志信息。
 | 
						|
 | 
						|
自定义 logger 请参考 [自定义日志](https://nonebot.dev/docs/appendices/log)
 | 
						|
以及 [`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
 | 
						|
  ```
 | 
						|
 | 
						|
## _class_ `LoguruHandler(<auto>)` {#LoguruHandler}
 | 
						|
 | 
						|
- **说明:** logging 与 loguru 之间的桥梁,将 logging 的日志转发到 loguru。
 | 
						|
 | 
						|
- **参数**
 | 
						|
 | 
						|
  auto
 | 
						|
 | 
						|
### _method_ `emit(record)` {#LoguruHandler-emit}
 | 
						|
 | 
						|
- **参数**
 | 
						|
 | 
						|
  - `record` (logging.LogRecord)
 | 
						|
 | 
						|
- **返回**
 | 
						|
 | 
						|
  - untyped
 | 
						|
 | 
						|
## _def_ `default_filter(record)` {#default-filter}
 | 
						|
 | 
						|
- **说明:** 默认的日志过滤器,根据 `config.log_level` 配置改变日志等级。
 | 
						|
 | 
						|
- **参数**
 | 
						|
 | 
						|
  - `record` (Record)
 | 
						|
 | 
						|
- **返回**
 | 
						|
 | 
						|
  - untyped
 | 
						|
 | 
						|
## _var_ `default_format` {#default-format}
 | 
						|
 | 
						|
- **类型:** str
 | 
						|
 | 
						|
- **说明:** 默认日志格式
 |