See also: Contributing Guide | Troubleshooting | Services
- Be concise but informative
- Use consistent formatting
- Include relevant context without being verbose
logger.info("Starting display refresh") # No "..." at the endlogger.info("Display refresh completed") # Simple past tenselogger.error("Display refresh failed") # No need for "ERROR:" prefixlogger.info(f"Loading page - {url}")
logger.info(f"Config parsed - URL: {url}")
logger.info(f"Screenshot saved - {path}")logger.info(f"Game state: {active} active, {scheduled} scheduled, {final} final")
logger.info(f"Memory available: {mb}MB")logger.error(f"Failed to connect - {e}") # Include exception after dashlogger.error("Connection timeout") # Simple descriptionlogger.info(f"Memory available: {mb}MB")
logger.info(f"System load: {load}")logger.info(f"Operation completed in {seconds}s")
logger.info(f"Next check in {interval} seconds")- Detailed diagnostic information
- Loop iterations, intermediate values
- Not shown in production
logger.debug(f"Checking game {game_id}")- Normal program flow
- State changes
- Important milestones
logger.info("Server ready")
logger.info("Starting screenshot capture")- Recoverable issues
- Degraded functionality
- Resource concerns
logger.warning("Low memory - proceeding with caution")
logger.warning("API rate limit approaching")- Failed operations
- Exceptions that affect functionality
- Need attention but not fatal
logger.error("Screenshot failed after 3 retries")
logger.error(f"API request failed - {e}")- System-level failures
- Unrecoverable errors
- Service stopping conditions
logger.critical("Out of memory - shutting down")
logger.critical("Configuration file missing")Worker logs use simple format since parent adds prefix:
# In worker
logger.info("Launching browser") # Becomes: [WORKER-ERR] Launching browserUse structured format for machine parsing:
logger.info(f"RESOURCE_SNAPSHOT: {json.dumps(snapshot_dict)}")Use clear markers:
logger.info("="*80)
logger.info("SYSTEM STARTING")
logger.info("="*80)# Bad
logger.error("ERROR: Failed to connect") # ERROR is already in the level
# Good
logger.error("Failed to connect")# Bad
logger.info("Starting process...") # Ellipsis unnecessary
logger.info("Process complete!!!") # Excessive exclamation
# Good
logger.info("Starting process")
logger.info("Process complete")# Bad - inconsistent variable formatting
logger.info(f"Loading: {url}")
logger.info(f"Saved to {path}")
logger.info(f"Memory={mb}MB")
# Good - consistent dash separator
logger.info(f"Loading - {url}")
logger.info(f"Saved - {path}")
logger.info(f"Memory available: {mb}MB")logger.info("Starting display update")
logger.info(f"Loading URL - {url}")
logger.debug(f"Browser args - {args}")
logger.info("Browser launched")
logger.info("Page loaded")
logger.info("Content detected")
logger.info(f"Screenshot saved - {path}")
logger.info("Display updated")logger.warning("Low memory detected")
logger.info("Attempting cleanup")
logger.info(f"Memory recovered: {mb}MB")
logger.error(f"Operation failed - {e}")
logger.info("Retrying in 10 seconds")