diff --git a/README.md b/README.md index f6646d5f..4504d371 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ Now run your app locally with: preswald run ``` -This command launches a development server, and Preswald will let you know where your app is hosted. Typically, itโ€™s here: +This command launches a development server, and Preswald will let you know where your app is hosted. Typically, it's here: ``` ๐ŸŒ App running at: http://localhost:8501 @@ -154,7 +154,8 @@ primaryColor = "#F89613" [logging] level = "INFO" # Options: DEBUG, INFO, WARNING, ERROR, CRITICAL -format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s" +format = "%(asctime)s.%(msecs)03d - %(name)s - %(levelname)s - %(message)s" +datefmt = "%Y-%m-%d %H:%M:%S" # Optional: Customize timestamp format ``` ## **Use Cases** @@ -169,7 +170,7 @@ format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s" ## **๐Ÿ“š Documentation** -Weโ€™re here to help! Check out our full documentation at [Preswald Docs](https://docs.preswald.com/). +We're here to help! Check out our full documentation at [Preswald Docs](https://docs.preswald.com/).
diff --git a/preswald/utils.py b/preswald/utils.py index 52da82fb..740977cd 100644 --- a/preswald/utils.py +++ b/preswald/utils.py @@ -63,10 +63,11 @@ def configure_logging(config_path: str | None = None, level: str | None = None): config_path: Path to preswald.toml file. If None, will look in current directory level: Directly specified logging level, overrides config file if provided """ - # Default configuration + # Default configuration with enhanced timestamp format log_config = { "level": "INFO", - "format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s", + "format": "%(asctime)s.%(msecs)03d - %(name)s - %(levelname)s - %(message)s", + "datefmt": "%Y-%m-%d %H:%M:%S", } # Try to load from config file @@ -86,16 +87,17 @@ def configure_logging(config_path: str | None = None, level: str | None = None): if level is not None: log_config["level"] = level - # Configure logging + # Configure logging with enhanced timestamp format logging.basicConfig( level=getattr(logging, log_config["level"].upper()), format=log_config["format"], + datefmt=log_config.get("datefmt", "%Y-%m-%d %H:%M:%S"), force=True, # This resets any existing handlers ) # Create logger for this module logger = logging.getLogger(__name__) - logger.debug(f"Logging configured with level {log_config['level']}") + logger.debug(f"Logging configured with level {log_config['level']} and enhanced timestamp format") return log_config["level"]