Compare commits
No commits in common. "5a4d867befe82bb9acfb74b7b225aafdab5afcbc" and "2bdfb7fe1f03d803e2cba7bf9005e8a47602149a" have entirely different histories.
5a4d867bef
...
2bdfb7fe1f
@ -14,7 +14,7 @@ logger = loggers.config.get_logger("somename")
|
||||
logger.info("abc")
|
||||
```
|
||||
|
||||
## 使用 config 的范例
|
||||
## 复杂一些的
|
||||
|
||||
```python title=use_config.py
|
||||
from lib_not_dr.loggers import config
|
||||
@ -110,32 +110,3 @@ config_version = 1
|
||||
file_name = "dr-{time}.log"
|
||||
|
||||
```
|
||||
|
||||
## 直接在代码里配置的案例
|
||||
|
||||
```python title=code_config.py
|
||||
from lib_not_dr import loggers
|
||||
|
||||
logger = loggers.config.get_logger("main")
|
||||
|
||||
# 比如你想在控制台输出所有,文件里输出 error 及以上
|
||||
error_stream = loggers.outstream.FileCacheOutputStream(file_name="check-err.log", level=loggers.LogLevel.warn)
|
||||
logger.add_output(error_stream)
|
||||
```
|
||||
|
||||
或者
|
||||
|
||||
```python title=fmt_log.py
|
||||
import sys
|
||||
from lib_not_dr import loggers
|
||||
|
||||
logger = loggers.config.get_logger("transfer")
|
||||
log_file_name = f"{time.strftime('%Y-%m-%d-%H-%M-%S', time.localtime())}-transfer.log"
|
||||
logger.add_output(FileCacheOutputStream(file_name=log_file_name, level=0))
|
||||
|
||||
# 使用命令行参数来调节等级
|
||||
if "-v" in sys.argv:
|
||||
logger.global_level = 10
|
||||
if "-vv" in sys.argv:
|
||||
logger.global_level = 5
|
||||
```
|
||||
|
@ -8,7 +8,7 @@
|
||||
"preview": "rspress preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"rspress": "^1.37.0",
|
||||
"rspress": "^1.35.1",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.6.3"
|
||||
}
|
||||
|
702
pnpm-lock.yaml
702
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user