Source code for thesis.core.logging.formatters

"""
Log formatting utilities for the thesis framework.

Provides consistent formatting for console and file output with
appropriate detail levels and coloring.
"""

__all__ = [
    "CONSOLE_FORMAT",
    "FILE_FORMAT",
    "get_console_format",
    "get_file_format",
]


# Console format with colors and emoji
CONSOLE_FORMAT = (
    "<green>{time:YYYY-MM-DD HH:mm:ss}</green> | "
    "<level>{level: <8}</level> | "
    "<cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> | "
    "<level>{message}</level>"
)

# File format with full details
FILE_FORMAT = (
    "{time:YYYY-MM-DD HH:mm:ss.SSS} | " "{level: <8} | " "{name}:{function}:{line} | " "{message}"
)


[docs] def get_console_format(verbose: bool = False) -> str: """ Get the console log format string. Args: verbose: If True, returns more detailed format Returns: Format string for console output """ if verbose: return ( "<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | " "<level>{level: <8}</level> | " "<cyan>{name}</cyan>:" "<cyan>{function}</cyan>:" "<cyan>{line}</cyan> | " "<level>{message}</level>" ) return CONSOLE_FORMAT
[docs] def get_file_format(minimal: bool = False) -> str: """ Get the file log format string. Args: minimal: If True, returns minimal format Returns: Format string for file output """ if minimal: return "{time:HH:mm:ss} | {level: <5} | {message}" return FILE_FORMAT