Skip to content
Snippets Groups Projects
Commit 0c7cb84a authored by James Abrenica's avatar James Abrenica
Browse files

added readme file

parent 6b570d59
No related branches found
No related tags found
No related merge requests found
# Chatbot Custom Logger FastAPI
A FastAPI application for logging chatbot and user events to MongoDB.
## Requirements
- Python 3.7+
- MongoDB
## Installation
1. **Clone the repository**:
```bash
git clone https://github.com/yourusername/chatbot-custom-logger-fast-api.git
cd chatbot-custom-logger-fast-api
2. **Create and activate a virtual environment**:
python -m venv venv
# On Windows
venv\Scripts\activate
(`.\venv\Scripts\activate`)
# On macOS/Linux
source venv/bin/activate
3. **Install dependencies:**:
pip install -r requirements.txt
4. **Run the application**:
uvicorn app.main:app --reload
\ No newline at end of file
No preview for this file type
No preview for this file type
......@@ -3,7 +3,8 @@ from app.models import BotEvent
from app.database import get_db
from bson import ObjectId
from pymongo.errors import PyMongoError
from app.logging import logger
from app.custom_logging import logger
bot_router = APIRouter()
......
......@@ -3,7 +3,7 @@ from app.models import UserEvent
from app.database import get_db
from bson import ObjectId
from pymongo.errors import PyMongoError
from app.logging import logger
from app.custom_logging import logger
user_router = APIRouter()
......@@ -13,7 +13,7 @@ async def log_user_event(event: UserEvent, db = Depends(get_db)):
event_dict = event.dict()
try:
result = collection.insert_one(event_dict)
event_dict["_id"] = str(result.inserted_id) # Convert ObjectId to string
event_dict["_id"] = str(result.inserted_id)
logger.info(f"User event logged: {event_dict}")
return {"message": "User event logged successfully", "event": event_dict}
except PyMongoError as e:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment