- 核心功能从 store/ 迁移至 oss/core/ 框架层 - 实现 NBPF 包格式:多重签名(Ed25519+RSA-PSS+HMAC)+ 多重加密(AES-256-GCM) - 实现 NIR 编译器:基于 compile()+marshal 的跨平台中间表示 - 新增 nebula nbpf CLI 命令组(pack/unpack/verify/sign/keygen) - 新增 19 个 NBPF 测试用例,覆盖全链路 - 彻底重写 README,大型项目标准框架风格,所有图表使用 SVG - 更新 LICENSE 版权声明 - 清理旧版 store 插件目录(已迁移至 oss/core)
47 lines
1.3 KiB
Python
47 lines
1.3 KiB
Python
"""日志系统 - 彩色日志"""
|
||
import sys
|
||
|
||
|
||
class Log:
|
||
"""通用彩色日志 - 所有插件可共用"""
|
||
|
||
_TTY = sys.stdout.isatty()
|
||
_C = {
|
||
"reset": "\033[0m",
|
||
"white": "\033[0;37m",
|
||
"yellow": "\033[1;33m",
|
||
"blue": "\033[1;34m",
|
||
"red": "\033[1;31m",
|
||
"green": "\033[0;32m",
|
||
}
|
||
|
||
@classmethod
|
||
def _c(cls, text: str, color: str) -> str:
|
||
if not cls._TTY:
|
||
return text
|
||
return f"{cls._C.get(color, '')}{text}{cls._C['reset']}"
|
||
|
||
@classmethod
|
||
def info(cls, tag: str, msg: str):
|
||
print(f"{cls._c(f'[{tag}]', 'white')} {cls._c(msg, 'white')}")
|
||
|
||
@classmethod
|
||
def warn(cls, tag: str, msg: str):
|
||
print(f"{cls._c(f'[{tag}]', 'yellow')} {cls._c('⚠', 'yellow')} {cls._c(msg, 'yellow')}")
|
||
|
||
@classmethod
|
||
def error(cls, tag: str, msg: str):
|
||
print(f"{cls._c(f'[{tag}]', 'red')} {cls._c('✗', 'red')} {cls._c(msg, 'red')}")
|
||
|
||
@classmethod
|
||
def tip(cls, tag: str, msg: str):
|
||
print(f"{cls._c(f'[{tag}]', 'blue')} {cls._c('ℹ', 'blue')} {cls._c(msg, 'blue')}")
|
||
|
||
@classmethod
|
||
def ok(cls, tag: str, msg: str):
|
||
print(f"{cls._c(f'[{tag}]', 'white')} {cls._c(msg, 'white')}")
|
||
|
||
@classmethod
|
||
def debug(cls, tag: str, msg: str):
|
||
cls.tip(tag, msg)
|