Nova Coder uses a structured logging system. Every action is logged with a timestamp, level, logger name, source file, and line number. JSON logging is supported for production environments.
Log Format
Text Format
2026-07-09 12:01:00 [INFO] novacoder.kernel - Planner task created (kernel.py:42)
JSON Format
{
"timestamp": "2026-07-09T12:01:00+00:00",
"level": "INFO",
"logger": "novacoder.kernel",
"message": "Planner task created",
"source": "kernel.py",
"line": 42
}
Configuration
logging:
level: INFO
format: text
file_path: ~/.config/novacoder/novacoder.log
console: true
Set format: json for machine-readable output.
Using the Logger
from novacoder.logging import get_logger
logger = get_logger("novacoder.workspace")
logger.info("Scanning project")
logger.error("Failed to read file", extra={"path": "main.py"})
The extra context is included in JSON log entries.
LoggingService
LoggingService is a kernel service that configures the root logger from the application configuration during boot. It attaches a BufferHandler that writes formatted records into novacoder.logging.buffer._log_buffer so the API and TUI can share a single log stream.
from novacoder.logging.service import LoggingService
from novacoder.config.settings import AppConfig
service = LoggingService(config=AppConfig())
service.initialize()
service.start()
Correlation IDs
Use ContextAdapter to attach correlation IDs to log entries:
logger = get_logger("novacoder.agents", extra={"correlation_id": "abc-123"})
Development Instructions
Adding a New Logger
- Use
get_logger("novacoder.<module>")to create a logger in your module. - Include
extrametadata for events that need structured querying. - Do not print directly to stdout.
Adding a Custom Formatter
- Subclass
StructuredFormatterinnovacoder/logging/logger.py. - Add a new format name to
LoggingConfig. - Update
configure_logging()to select the formatter based on config.
Testing Logging
Use caplog or attach a temporary handler in tests. The shared buffer can be inspected in tests via novacoder.logging.buffer.get_log_buffer().
def test_logs_info(caplog):
with caplog.at_level("INFO"):
logger.info("Started")
assert "Started" in caplog.text
Best Practices
- Always use
get_loggerinstead ofprint. - Include structured
extrametadata for important events. - Use log levels appropriately:
DEBUGfor detail,INFOfor milestones,WARNINGfor recoverable issues,ERRORfor failures. - Rotate log files in production deployments.
Related Documentation
- Configuration
- Kernel