log_debug()
def log_debug(message)Logs a debug-level message.
Debug messages are the most verbose and should be used for detailed diagnostic information. They are typically disabled in production but enabled during development and troubleshooting.
Args
message: string: The debug message to log. Can include string formatting.
Returns
None
log_error()
def log_error(message)Logs an error-level message.
Error messages indicate failures in specific operations. The error is logged but execution continues. Use log_fatal() if you need to terminate execution.
Args
message: string: The error message to log.
Returns
None
log_fatal()
def log_fatal(message)Logs an error message and terminates script execution.
Fatal errors indicate unrecoverable problems that prevent further execution. The message is logged at error level, then script execution stops immediately. Use this for critical failures where recovery is impossible.
Raises: Error: Always raises an error with the provided message, terminating execution
Args
message: string: The fatal error message to log before termination.
Returns
None (execution never returns)
log_info()
def log_info(message)Logs an info-level message.
Informational messages provide general information about program execution. This is the default log level and is suitable for normal operation messages that users should know about.
Args
message: string: The info message to log.
Returns
None
log_set_format()
def log_set_format(format)Sets the output format for log messages.
Changes how log messages are formatted when displayed. The format applies to all subsequent log messages. Different formats are useful for different scenarios: human-readable text for interactive use, JSON for log aggregation.
Raises: Error: If an invalid format is provided
Args
format: string: One of “text” or “json”. - “text”: Human-readable format with timestamps (default) Example: “[2024-01-15 10:30:45.123] [INFO] Processing started” - “json”: Structured JSON format for log parsers Example: {“timestamp”: “2024-01-15T10:30:45.123Z”, “level”: “info”, “message”: “Processing started”}
Returns
None
log_set_level()
def log_set_level(level)Sets the minimum log level for all subsequent log messages.
Only messages at or above the specified level will be logged. This is useful for controlling verbosity during script execution. The log level can be overridden at runtime via the SPACES_ENV_LOG environment variable.
Raises: Error: If an invalid log level is provided
Args
level: string: One of “trace”, “debug”, “info”, “warn”, “error”, or “off”. - “trace”: Most verbose, includes everything - “debug”: Detailed diagnostic information - “info”: Informational messages (default) - “warn”: Warning messages and above - “error”: Error messages only - “off”: Disable all logging
Returns
None
log_trace()
def log_trace(message)Logs a trace-level message.
Trace messages are the most verbose level and are disabled by default.
Enable them with log_set_level("trace") or the SPACES_ENV_LOG=trace
environment variable. Use trace for very fine-grained diagnostic output
such as per-iteration loop state or low-level I/O details.
Args
message: string: The trace message to log.
Returns
None
log_warn()
def log_warn(message)Logs a warning-level message.
Warning messages indicate potentially problematic situations that should be investigated but don’t prevent normal execution. Use this for deprecated features, unusual conditions, or resource constraints.
Args
message: string: The warning message to log.
Returns
None