Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions robyn/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Logger:

def __init__(self):
self.logger = logging.getLogger(__name__)
self.logger.addHandler(logging.NullHandler())

def _format_msg(
self,
Expand Down
16 changes: 8 additions & 8 deletions robyn/reloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def compile_rust_files(directory_path: str) -> List[str]:
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],
Expand All @@ -26,9 +26,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
Expand Down Expand Up @@ -63,18 +63,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)


Expand Down Expand Up @@ -127,7 +127,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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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 print() or ensuring logging is configured as suggested above.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@robyn/reloader.py` around lines 128 - 130, The "Reloading the server" message
in the reload method may be dropped by unconfigured logging; update the reload
function (method reload) to emit CLI-facing output directly (use
print("Reloading the server")) instead of logger.info, or alternatively ensure
the module-level logger (logger) has a CLI handler before calling reload (e.g.,
configure a StreamHandler/basicConfig during initialization where the server is
started). Make the change in the reload method (and ensure consistency with
stop_server if it also needs CLI-visible messages).


new_env = os.environ.copy()
new_env["IS_RELOADER_RUNNING"] = "True" # This is used to check if a reloader is already running
Expand Down
5 changes: 4 additions & 1 deletion robyn/responses.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import asyncio
import logging
import mimetypes
import os
from typing import AsyncGenerator, Generator, Optional, Union

from robyn.robyn import Headers, Response

logger = logging.getLogger(__name__)


class FileResponse:
def __init__(
Expand Down Expand Up @@ -117,7 +120,7 @@ async def get_next():
raise StopIteration
except Exception as e:
# Log error and stop iteration
print(f"Error in async generator: {e}")
logger.exception("Error in async generator: %s", e)
raise StopIteration


Expand Down
Loading