Spaces:
Paused
Paused
Commit
•
716758b
1
Parent(s):
e51c8cf
Add logging configuration to main.py
Browse files
main.py
CHANGED
@@ -15,16 +15,29 @@ from fastapi.middleware.cors import CORSMiddleware
|
|
15 |
from fastapi.responses import JSONResponse
|
16 |
from httpx import AsyncClient
|
17 |
from huggingface_hub import CommitScheduler, DatasetCard, HfApi, hf_hub_download, whoami
|
18 |
-
from huggingface_hub.utils import disable_progress_bars
|
19 |
from huggingface_hub.utils._errors import HTTPError
|
20 |
from langfuse.openai import AsyncOpenAI # OpenAI integration
|
21 |
from pydantic import BaseModel, Field
|
22 |
from starlette.responses import RedirectResponse
|
23 |
from card_processing import parse_markdown, try_load_text, is_empty_template
|
|
|
|
|
|
|
24 |
|
25 |
disable_progress_bars()
|
26 |
load_dotenv()
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
Gb = 1073741824
|
30 |
cache.setup("disk://", size_limit=16 * Gb) # configure as in-memory cache
|
|
|
15 |
from fastapi.responses import JSONResponse
|
16 |
from httpx import AsyncClient
|
17 |
from huggingface_hub import CommitScheduler, DatasetCard, HfApi, hf_hub_download, whoami
|
18 |
+
from huggingface_hub.utils import disable_progress_bars
|
19 |
from huggingface_hub.utils._errors import HTTPError
|
20 |
from langfuse.openai import AsyncOpenAI # OpenAI integration
|
21 |
from pydantic import BaseModel, Field
|
22 |
from starlette.responses import RedirectResponse
|
23 |
from card_processing import parse_markdown, try_load_text, is_empty_template
|
24 |
+
import logging
|
25 |
+
import logging.config
|
26 |
+
import yaml
|
27 |
|
28 |
disable_progress_bars()
|
29 |
load_dotenv()
|
30 |
+
|
31 |
+
# Load the logging configuration from the YAML file
|
32 |
+
with open("log_conf.yaml", "r") as f:
|
33 |
+
log_config = yaml.safe_load(f.read())
|
34 |
+
logging.config.dictConfig(log_config)
|
35 |
+
|
36 |
+
# Create a logger for your application
|
37 |
+
logger = logging.getLogger("app")
|
38 |
+
|
39 |
+
# Use the logger in your application
|
40 |
+
logger.info("Application started")
|
41 |
|
42 |
Gb = 1073741824
|
43 |
cache.setup("disk://", size_limit=16 * Gb) # configure as in-memory cache
|