agentbox.template.logger
Classes:
- DefaultBuildLogger –
- DefaultBuildLoggerInitialState –
- LogEntry – Represents a single log entry from the template build process.
- LogEntryEnd – Special log entry indicating the end of a build process.
- LogEntryStart – Special log entry indicating the start of a build process.
Functions:
- default_build_logger – Create a default build logger with animated timer display.
- set_interval – Returns a stop function that can be called to cancel the interval.
Attributes:
- DEFAULT_LEVEL (
LogEntryLevel) – Colored labels for each log level. - LogEntryLevel –
- TIMER_UPDATE_INTERVAL_MS – Default minimum log level to display.
- level_order –
- levels (
Dict[LogEntryLevel, tuple[str, Style]]) – Numeric ordering of log levels for comparison (lower = less severe).
agentbox.template.logger.DEFAULT_LEVEL
DEFAULT_LEVEL: LogEntryLevel = 'info'Colored labels for each log level.
agentbox.template.logger.DefaultBuildLogger
DefaultBuildLogger(min_level=None)Functions:
- logger –
agentbox.template.logger.DefaultBuildLogger.logger
logger(log)agentbox.template.logger.DefaultBuildLoggerInitialState
Bases: TypedDict
Attributes:
- animation_frame (
int) – - start_time (
float) – - timer (
Optional[Callable[[], None]]) –
agentbox.template.logger.DefaultBuildLoggerInitialState.animation_frame
animation_frame: intagentbox.template.logger.DefaultBuildLoggerInitialState.start_time
start_time: floatagentbox.template.logger.DefaultBuildLoggerInitialState.timer
timer: Optional[Callable[[], None]]agentbox.template.logger.LogEntry
LogEntry(timestamp, level, message)Represents a single log entry from the template build process.
Attributes:
- level (
LogEntryLevel) – - message (
str) – - timestamp (
datetime) –
agentbox.template.logger.LogEntry.level
level: LogEntryLevelagentbox.template.logger.LogEntry.message
message: stragentbox.template.logger.LogEntry.timestamp
timestamp: datetimeagentbox.template.logger.LogEntryEnd
LogEntryEnd(timestamp, level, message)Bases: LogEntry
Special log entry indicating the end of a build process.
Attributes:
- level (
LogEntryLevel) – - message (
str) – - timestamp (
datetime) –
agentbox.template.logger.LogEntryEnd.level
level: LogEntryLevel = field(default='debug', init=False)agentbox.template.logger.LogEntryEnd.message
message: stragentbox.template.logger.LogEntryEnd.timestamp
timestamp: datetimeagentbox.template.logger.LogEntryLevel
LogEntryLevel = Literal['debug', 'info', 'warn', 'error']agentbox.template.logger.LogEntryStart
LogEntryStart(timestamp, level, message)Bases: LogEntry
Special log entry indicating the start of a build process.
Attributes:
- level (
LogEntryLevel) – - message (
str) – - timestamp (
datetime) –
agentbox.template.logger.LogEntryStart.level
level: LogEntryLevel = field(default='debug', init=False)agentbox.template.logger.LogEntryStart.message
message: stragentbox.template.logger.LogEntryStart.timestamp
timestamp: datetimeagentbox.template.logger.TIMER_UPDATE_INTERVAL_MS
TIMER_UPDATE_INTERVAL_MS = 150Default minimum log level to display.
agentbox.template.logger.default_build_logger
default_build_logger(min_level=None)Create a default build logger with animated timer display.
:param min_level: Minimum log level to display (default: 'info')
:return: Logger function that accepts LogEntry instances
Example
from agentbox import Template, default_build_logger
template = Template().from_python_image()
# Use with build - implementation would be in build_async module
# await Template.build(template,
# alias='my-template',
# on_build_logs=default_build_logger(min_level='debug')
# )agentbox.template.logger.level_order
level_order = {'debug': 0, 'info': 1, 'warn': 2, 'error': 3}agentbox.template.logger.levels
levels: Dict[LogEntryLevel, tuple[str, Style]] = {
"error": ("ERROR", Style(color="red")),
"warn": ("WARN ", Style(color="#FF4400")),
"info": ("INFO ", Style(color="#FF8800")),
"debug": ("DEBUG", Style(color="bright_black")),
}Numeric ordering of log levels for comparison (lower = less severe).
agentbox.template.logger.set_interval
set_interval(func, interval)Returns a stop function that can be called to cancel the interval.
Similar to JavaScript's setInterval.
:param func: Function to execute at each interval :param interval: Interval duration in seconds
:return: Stop function that can be called to cancel the interval