Fastapi-vue-setup 1.7.2 logging fixes.

This commit is contained in:
LeoVasanko committed 2026-09-18 19:07:33 +00:00
1 parent 4de164c457
commit b5733657f9
3 files changed
+12 -15

No files matched your search

+10 -13
View File
@@ -10,23 +10,20 @@ from pathlib import Path
MIN_NODE_VERSION = 20
# Duplicated from fastapi_vue.logging because build environment is isolated
_LEVEL_EMOJI = {
logging.DEBUG: "🐛",
logging.INFO: "🔷",
logging.WARNING: "❗",
logging.ERROR: "🛑",
logging.CRITICAL: "🚨",
}
class _Formatter(logging.Formatter):
"""Emoji level prefix formatter, mirroring fastapi_vue.logging.Formatter."""
"""Prefix formatter, intentionally different from fastapi_vue.logging.
INFO and below pass through unprefixed so messages can use their own
markings (>>>, ###); WARNING and above get an emoji prefix.
"""
def format(self, record: logging.LogRecord) -> str:
emoji = _LEVEL_EMOJI.get(record.levelno)
prefix = f"{emoji} " if emoji else f"{record.levelname}: "
return prefix + record.getMessage()
if record.levelno >= logging.ERROR:
return f"🛑 {record.getMessage()}"
if record.levelno >= logging.WARNING:
return f"💣 {record.getMessage()}"
return record.getMessage()
_handler = logging.StreamHandler()