🔧 chore(main.py): configure logger in create_app function to improve logging configuration
🔧 chore(logger.py): change default log level to DEBUG in configure function for more detailed logging
This commit is contained in:
parent
80db6b910e
commit
564b113c3a
2 changed files with 16 additions and 9 deletions
|
|
@ -8,10 +8,15 @@ from fastapi.staticfiles import StaticFiles
|
||||||
from langflow.api import router
|
from langflow.api import router
|
||||||
from langflow.database.base import create_db_and_tables
|
from langflow.database.base import create_db_and_tables
|
||||||
from langflow.interface.utils import setup_llm_caching
|
from langflow.interface.utils import setup_llm_caching
|
||||||
|
from langflow.utils.logger import configure
|
||||||
|
|
||||||
|
|
||||||
def create_app():
|
def create_app():
|
||||||
"""Create the FastAPI app and include the router."""
|
"""Create the FastAPI app and include the router."""
|
||||||
|
# get the current log level
|
||||||
|
# log_level = logging.getLogger().getEffectiveLevel()
|
||||||
|
# log_level_name = logging.getLevelName(log_level)
|
||||||
|
configure()
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
|
|
@ -73,10 +78,16 @@ def setup_app(static_files_dir: Optional[Path] = None) -> FastAPI:
|
||||||
return app
|
return app
|
||||||
|
|
||||||
|
|
||||||
app = create_app()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import uvicorn
|
import uvicorn
|
||||||
|
from langflow.utils.util import get_number_of_workers
|
||||||
|
|
||||||
uvicorn.run(app, host="127.0.0.1", port=7860)
|
configure()
|
||||||
|
uvicorn.run(
|
||||||
|
create_app,
|
||||||
|
host="127.0.0.1",
|
||||||
|
port=7860,
|
||||||
|
workers=get_number_of_workers(),
|
||||||
|
log_level="debug",
|
||||||
|
reload=True,
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ from rich.logging import RichHandler
|
||||||
logger = logging.getLogger("langflow")
|
logger = logging.getLogger("langflow")
|
||||||
|
|
||||||
|
|
||||||
def configure(log_level: str = "INFO", log_file: Path = None): # type: ignore
|
def configure(log_level: str = "DEBUG", log_file: Path = None): # type: ignore
|
||||||
log_format = "%(asctime)s - %(levelname)s - %(message)s"
|
log_format = "%(asctime)s - %(levelname)s - %(message)s"
|
||||||
log_level_value = getattr(logging, log_level.upper(), logging.INFO)
|
log_level_value = getattr(logging, log_level.upper(), logging.INFO)
|
||||||
|
|
||||||
|
|
@ -28,7 +28,3 @@ def configure(log_level: str = "INFO", log_file: Path = None): # type: ignore
|
||||||
logger.info(f"Logger set up with log level: {log_level_value}({log_level})")
|
logger.info(f"Logger set up with log level: {log_level_value}({log_level})")
|
||||||
if log_file:
|
if log_file:
|
||||||
logger.info(f"Log file: {log_file}")
|
logger.info(f"Log file: {log_file}")
|
||||||
|
|
||||||
|
|
||||||
# Configure default logger
|
|
||||||
configure()
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue