mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-16 04:35:49 +00:00
🔒 Filter bot_token in log
This commit is contained in:
parent
d0cf14e4b0
commit
683ec7e8df
@ -22,6 +22,7 @@ from rich.traceback import (
|
|||||||
Traceback as BaseTraceback,
|
Traceback as BaseTraceback,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from core.config import config
|
||||||
from utils.log._style import MonokaiProStyle
|
from utils.log._style import MonokaiProStyle
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
@ -199,7 +200,7 @@ class Traceback(BaseTraceback):
|
|||||||
name=frame_summary.f_code.co_name,
|
name=frame_summary.f_code.co_name,
|
||||||
locals={
|
locals={
|
||||||
key: pretty.traverse(
|
key: pretty.traverse(
|
||||||
value,
|
Traceback.filter_value(value),
|
||||||
max_length=locals_max_length,
|
max_length=locals_max_length,
|
||||||
max_string=locals_max_string,
|
max_string=locals_max_string,
|
||||||
max_depth=locals_max_depth,
|
max_depth=locals_max_depth,
|
||||||
@ -343,3 +344,9 @@ class Traceback(BaseTraceback):
|
|||||||
if frame.locals
|
if frame.locals
|
||||||
else syntax
|
else syntax
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def filter_value(value: Any) -> Any:
|
||||||
|
if isinstance(value, str):
|
||||||
|
return value.replace(config.bot_token, "TOKEN")
|
||||||
|
return value
|
||||||
|
Loading…
Reference in New Issue
Block a user