🚚 重命名pliblogpy-logiliteal

This commit is contained in:
Nanaloveyuki
2025-07-28 11:47:59 +08:00
parent d788b27b1c
commit 9b035ca692
5 changed files with 27 additions and 20 deletions

View File

@ -1,10 +1,11 @@
"""
pliblog - 简易,现代化具有色彩的日志记录器 / Easy, Modern and colorful Logger
py-logiliteal - 简易,现代化具有色彩的日志记录器
py-logiliteal's config settings, used to set py-logiliteal's global config
"""
# encoding = utf-8
# python 3.13.5
from .utils import get_config, set_config, reset_config, get_asctime, get_date, get_time, get_weekday, fmt_console, fmt_placeholder, fmt_message, fmt_level_name
from .utils import get_config, set_config, reset_config, get_asctime, get_date, get_time, get_weekday, fmt_console, fmt_placeholder, fmt_message, fmt_level_name, get_style, set_style, reset_style
from .levels import Logger
__all__ = [
@ -19,5 +20,7 @@ __all__ = [
"fmt_placeholder",
"fmt_message",
"fmt_level_name",
"Logger"
"set_color",
"set_bg_color",
"Logger" # 日志记录器非实例化
]

View File

@ -1,5 +1,6 @@
"""
工具函数 / Utility functions
工具函数
Utility functions
"""
# encoding = utf-8
# python 3.13.5
@ -7,6 +8,7 @@
from .configs import get_config, set_config, reset_config
from .time import get_asctime, get_date, get_time, get_weekday
from .fmt import fmt_console, fmt_placeholder, fmt_message, fmt_level_name
from .styles import set_color, set_bg_color
__all__ = [
"get_config",
@ -20,4 +22,6 @@ __all__ = [
"fmt_placeholder",
"fmt_message",
"fmt_level_name",
"set_color",
"set_bg_color",
]

View File

@ -1,6 +1,6 @@
"""
pliblog的配置设置,用于设置pliblog的全局配置
pliblog's config settings, used to set pliblog's global config
py-logiliteal的配置设置,用于设置py-logiliteal的全局配置
py-logiliteal's config settings, used to set py-logiliteal's global config
"""
# encoding = utf-8
@ -26,7 +26,7 @@ DEFAULT_CONFIG = {
}
from typing import Union, Optional
import logging
from logging import error, info
import json
def get_config(select: str = None) -> Union[dict, str, bool, int, None]:
@ -48,10 +48,10 @@ def get_config(select: str = None) -> Union[dict, str, bool, int, None]:
return DEFAULT_CONFIG[select]
return DEFAULT_CONFIG
except KeyError as e:
logging.error(f"配置项 '{select}' 不存在")
error(f"配置项 '{select}' 不存在")
return None
except Exception as e:
logging.error(f"读取配置文件失败: {e}")
error(f"读取配置文件失败: {e}")
return None
import shutil
@ -84,7 +84,7 @@ def set_config(select: str, value: Union[dict, str, bool, int, None]) -> tuple[b
with open(DEFAULT_CONFIG_PATH, "r", encoding="utf-8") as f:
verify_config = json.load(f)
if verify_config.get(select) != value:
error(f"配置项 '{select}' 设置失败,值为 {value}")
shutil.move(backup_path, DEFAULT_CONFIG_PATH)
return False, f"配置项 '{select}' 设置失败,已恢复备份"
@ -92,13 +92,13 @@ def set_config(select: str, value: Union[dict, str, bool, int, None]) -> tuple[b
return True, f"配置项 '{select}' 设置成功"
except json.JSONDecodeError as e:
logging.error(f"配置文件格式错误: {e}")
error(f"配置文件格式错误: {e}")
return False, f"配置文件格式错误: {str(e)}"
except PermissionError:
logging.error(f"没有权限操作配置文件: {DEFAULT_CONFIG_PATH}")
error(f"没有权限操作配置文件: {DEFAULT_CONFIG_PATH}")
return False, "没有权限操作配置文件"
except Exception as e:
logging.error(f"设置配置文件失败: {e}")
error(f"设置配置文件失败: {e}")
if Path(backup_path).exists():
shutil.move(backup_path, DEFAULT_CONFIG_PATH)
@ -128,11 +128,11 @@ def reset_config() -> tuple[bool, Optional[str]]:
json.dump(DEFAULT_CONFIG, f, indent=4)
return True
except PermissionError:
logging.error(f"权限不足,无法操作配置文件: {DEFAULT_CONFIG_PATH}")
error(f"权限不足,无法操作配置文件: {DEFAULT_CONFIG_PATH}")
return False, "权限不足,无法重置配置"
except json.JSONDecodeError:
logging.error("配置文件格式错误,无法解析")
error("配置文件格式错误,无法解析")
return False, "配置文件格式错误,无法重置"
except Exception as e:
logging.error(f"重置配置文件失败: {e}")
error(f"重置配置文件失败: {e}")
return False, f"重置配置失败: {str(e)}"

View File

@ -1,6 +1,6 @@
"""
pliblog的格式化工具,用于格式化日志输出
pliblog's formatter, used to format log output
py-logiliteal的格式化工具,用于格式化日志输出
py-logiliteal's formatter, used to format log output
"""
# encoding = utf-8

View File

@ -1,6 +1,6 @@
"""
pliblog的样式工具,用于格式化日志输出
pliblog's style tools, used to format log output
py-logiliteal的样式工具,用于格式化日志输出
py-logiliteal's style tools, used to format log output
"""
# encoding = utf-8