-
-
Notifications
You must be signed in to change notification settings - Fork 329
fix: replace print() with logger in responses, reloader, and __init__ #1328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
b8dc528
f9ae975
6661480
2010cc6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import glob | ||
| import logging | ||
| import os | ||
| import signal | ||
| import subprocess | ||
|
|
@@ -11,13 +12,18 @@ | |
|
|
||
| from robyn.logger import Colors, logger | ||
|
|
||
| # Ensure logging is configured before any logger calls that may run | ||
| # at module level (e.g. compile_rust_files called during import), | ||
| # before Robyn.__init__ calls logging.basicConfig(). | ||
| logging.basicConfig(level=logging.INFO) | ||
|
|
||
|
|
||
| def compile_rust_files(directory_path: str) -> List[str]: | ||
| rust_files = glob.glob(os.path.join(directory_path, "**/*.rs"), recursive=True) | ||
| rust_binaries: list[str] = [] | ||
|
|
||
| for rust_file in rust_files: | ||
| print(f"Compiling rust file: {rust_file}") | ||
| logger.info("Compiling rust file: %s", rust_file) | ||
|
|
||
| result = subprocess.run( | ||
| [sys.executable, "-m", "rustimport", "build", rust_file], | ||
|
|
@@ -26,9 +32,9 @@ def compile_rust_files(directory_path: str) -> List[str]: | |
| start_new_session=False, | ||
| ) | ||
| if result.returncode != 0: | ||
| print(f"Error compiling rust file: {rust_file} \n {result.stderr.decode('utf-8')} \n {result.stdout.decode('utf-8')}") | ||
| logger.error("Error compiling rust file: %s\n%s\n%s", rust_file, result.stderr.decode("utf-8"), result.stdout.decode("utf-8")) | ||
| else: | ||
| print(f"Compiled rust file: {rust_file}") | ||
| logger.info("Compiled rust file: %s", rust_file) | ||
| rust_file_base = rust_file.removesuffix(".rs") | ||
|
|
||
| # Define the search pattern for the binary file | ||
|
|
@@ -63,18 +69,18 @@ def create_rust_file(file_name: str) -> None: | |
| ) | ||
|
|
||
| if result.returncode != 0: | ||
| print( | ||
| "Error creating rust file : %s %s", | ||
| logger.error( | ||
| "Error creating rust file: %s %s", | ||
| result.stderr.decode("utf-8"), | ||
| result.stdout.decode("utf-8"), | ||
| ) | ||
| else: | ||
| print("Created rust file : %s", rust_file) | ||
| logger.info("Created rust file: %s", rust_file) | ||
|
|
||
|
|
||
| def clean_rust_binaries(rust_binaries: List[str]) -> None: | ||
| for file in rust_binaries: | ||
| print("Cleaning rust file : %s", file) | ||
| logger.info("Cleaning rust file: %s", file) | ||
| os.remove(file) | ||
|
|
||
|
|
||
|
|
@@ -127,7 +133,7 @@ def stop_server(self) -> None: | |
|
|
||
| def reload(self) -> None: | ||
| self.stop_server() | ||
| print("Reloading the server") | ||
| logger.info("Reloading the server") | ||
|
Comment on lines
128
to
+130
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reload message may not appear without handler configuration. The "Reloading the server" message is important user feedback during hot reload. With the logging handler issue, this message will be silently dropped. Given this is CLI-facing feedback, consider keeping this as 🤖 Prompt for AI Agents |
||
|
|
||
| new_env = os.environ.copy() | ||
| new_env["IS_RELOADER_RUNNING"] = "True" # This is used to check if a reloader is already running | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.