diff options
author | 2021-03-15 02:14:21 +0300 | |
---|---|---|
committer | 2021-03-15 02:16:29 +0300 | |
commit | 4f4dac9c8c863646a8292a9a2db53c0651d96b37 (patch) | |
tree | e4274fddbd1dd8544d696533c1ffc7374ee86423 /backend/routes/admin.py | |
parent | Adds Logging To Helpers (diff) |
Adds Logging For Routeslogging
Adds logging for most routes, to make it easier to debug the routes, and
keep a better record of major changes. Most operations would not get
logged, except the beginning of a more sensitive operation, especially
ones that require admin permissions.
Signed-off-by: Hassan Abouelela <[email protected]>
Diffstat (limited to 'backend/routes/admin.py')
-rw-r--r-- | backend/routes/admin.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/backend/routes/admin.py b/backend/routes/admin.py index 5254f8b..c37370e 100644 --- a/backend/routes/admin.py +++ b/backend/routes/admin.py @@ -1,6 +1,8 @@ """ Adds new admin user. """ +import logging + from pydantic import BaseModel, Field from spectree import Response from starlette.authentication import requires @@ -10,6 +12,8 @@ from starlette.responses import JSONResponse from backend.route import Route from backend.validation import ErrorMessage, OkayResponse, api +logger = logging.getLogger(__name__) + class AdminModel(BaseModel): id: str = Field(alias="_id") @@ -32,6 +36,8 @@ class AdminRoute(Route): data = await request.json() admin = AdminModel(**data) + logger.info(f"Trying to add a new admin with ID: {admin.id}") + if await request.state.db.admins.find_one( {"_id": admin.id} ): |