{"id":19519096,"url":"https://github.com/notsooshariff/error-logger-api","last_synced_at":"2026-04-18T17:33:39.436Z","repository":{"id":246119547,"uuid":"820154371","full_name":"NotSooShariff/error-logger-api","owner":"NotSooShariff","description":"An internal API that I use to collect logs across my servers and projects and retrieve them to trigger webhooks and notifications","archived":false,"fork":false,"pushed_at":"2024-06-26T18:43:28.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-09T20:12:16.570Z","etag":null,"topics":["docker","error-handling","error-monitoring","error-reporting","fastapi","python-api"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NotSooShariff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-06-25T23:11:47.000Z","updated_at":"2024-10-22T17:18:53.000Z","dependencies_parsed_at":"2024-06-26T00:28:47.376Z","dependency_job_id":"bad35dc7-fae0-4645-9877-870e1b07b9d3","html_url":"https://github.com/NotSooShariff/error-logger-api","commit_stats":null,"previous_names":["notsooshariff/error-logger-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/NotSooShariff/error-logger-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotSooShariff%2Ferror-logger-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotSooShariff%2Ferror-logger-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotSooShariff%2Ferror-logger-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotSooShariff%2Ferror-logger-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NotSooShariff","download_url":"https://codeload.github.com/NotSooShariff/error-logger-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotSooShariff%2Ferror-logger-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31978022,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T17:30:12.329Z","status":"ssl_error","status_checked_at":"2026-04-18T17:29:59.069Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","error-handling","error-monitoring","error-reporting","fastapi","python-api"],"created_at":"2024-11-11T00:16:18.862Z","updated_at":"2026-04-18T17:33:39.414Z","avatar_url":"https://github.com/NotSooShariff.png","language":"Python","readme":"## Error Logger API Documentation\n\nThis documentation provides a comprehensive guide on how to use the Error Logger API. It is an API that I use personally to send error logs from all of my various servers and projects, store them in a MongoDB database, so that I can use webhooks and other means to get notified when any of my projects run into an error.\n\n### Starting the server\nOnce you install the `requirements.txt` and add your Database URL to the `.env` file, you can use this command to start the server.\n```\nuvicorn src.main:app --reload\n```\n\nLocal Base URL on Startup:\n```\nhttp://127.0.0.1:8000\n```\n\n### Authentication\n\nThe `POST /log` endpoint requires Basic Authentication. It has the following credentials out of the box:\n- **Username**: `admin`\n- **Password**: `password`\n\n### Endpoints\n\n#### 1. POST /log\nLogs an error to the database.\n\n- **URL**: `/log`\n- **Method**: `POST`\n- **Authentication**: Basic Authentication\n- **Request Body**:\n  ```json\n  {\n      \"project_source\": \"string\",\n      \"timestamp\": \"ISO 8601 format string\",\n      \"error_message\": \"string\",\n      \"additional_info\": \"string\"\n  }\n  ```\n- **Response**:\n  - **Success** (200 OK):\n    ```json\n    {\n        \"status\": \"success\",\n        \"id\": \"string\"\n    }\n    ```\n  - **Authentication Failure** (401 Unauthorized):\n    ```json\n    {\n        \"detail\": \"Invalid authentication credentials\"\n    }\n    ```\n\n#### 2. GET /logs\nRetrieves a list of all error logs.\n\n- **URL**: `/logs`\n- **Method**: `GET`\n- **Request Parameters**:\n  - **skip** (optional, integer): Number of logs to skip.\n  - **limit** (optional, integer): Maximum number of logs to return.\n- **Response** (200 OK):\n  ```json\n  [\n      {\n          \"project_source\": \"string\",\n          \"timestamp\": \"ISO 8601 format string\",\n          \"error_message\": \"string\",\n          \"additional_info\": \"string\"\n      },\n      ...\n  ]\n  ```\n\n#### 3. GET /current\nRetrieves all error logs from the current day (Indian Standard Time).\n\n- **URL**: `/current`\n- **Method**: `GET`\n- **Response** (200 OK):\n  ```json\n  [\n      {\n          \"project_source\": \"string\",\n          \"timestamp\": \"ISO 8601 format string\",\n          \"error_message\": \"string\",\n          \"additional_info\": \"string\"\n      },\n      ...\n  ]\n  ```\n\n#### 4. GET /analytics\nRetrieves a list of all analytics logs.\n\n- **URL**: `/analytics`\n- **Method**: `GET`\n- **Request Parameters**:\n  - **skip** (optional, integer): Number of logs to skip.\n  - **limit** (optional, integer): Maximum number of logs to return.\n- **Response** (200 OK):\n  ```json\n  [\n      {\n          \"endpoint\": \"string\",\n          \"method\": \"string\",\n          \"ip_address\": \"string\",\n          \"params\": {},\n          \"response_status\": \"integer\",\n          \"timestamp\": \"ISO 8601 format string\"\n      },\n      ...\n  ]\n  ```\n\n### Examples\n\n#### Python\n\n##### Posting an Error Log\n```python\nimport requests\nfrom requests.auth import HTTPBasicAuth\nimport datetime\n\nurl = \"http://127.0.0.1:8000/log\"\ndata = {\n    \"project_source\": \"TestProject\",\n    \"timestamp\": datetime.datetime.now().isoformat(),\n    \"error_message\": \"Sample error message\",\n    \"additional_info\": \"Additional info\"\n}\n\nresponse = requests.post(url, json=data, auth=HTTPBasicAuth('admin', 'password'))\nprint(response.json())\n```\n\n##### Retrieving All Logs\n```python\nimport requests\n\nurl = \"http://127.0.0.1:8000/logs\"\nresponse = requests.get(url)\nprint(response.json())\n```\n\n##### Retrieving Current Day Logs\n```python\nimport requests\n\nurl = \"http://127.0.0.1:8000/current\"\nresponse = requests.get(url)\nprint(response.json())\n```\n\n##### Retrieving Analytics Logs\n```python\nimport requests\n\nurl = \"http://127.0.0.1:8000/analytics\"\nresponse = requests.get(url)\nprint(response.json())\n```\n\n#### JavaScript\n\n##### Posting an Error Log\n```javascript\nconst axios = require('axios');\nconst moment = require('moment');\n\nconst url = 'http://127.0.0.1:8000/log';\nconst data = {\n    project_source: \"TestProject\",\n    timestamp: moment().toISOString(),\n    error_message: \"Sample error message\",\n    additional_info: \"Additional info\"\n};\n\naxios.post(url, data, {\n    auth: {\n        username: 'admin',\n        password: 'password'\n    }\n})\n.then(response =\u003e {\n    console.log(response.data);\n})\n.catch(error =\u003e {\n    console.error(error);\n});\n```\n\n##### Retrieving All Logs\n```javascript\nconst axios = require('axios');\n\nconst url = 'http://127.0.0.1:8000/logs';\n\naxios.get(url)\n.then(response =\u003e {\n    console.log(response.data);\n})\n.catch(error =\u003e {\n    console.error(error);\n});\n```\n\n##### Retrieving Current Day Logs\n```javascript\nconst axios = require('axios');\n\nconst url = 'http://127.0.0.1:8000/current';\n\naxios.get(url)\n.then(response =\u003e {\n    console.log(response.data);\n})\n.catch(error =\u003e {\n    console.error(error);\n});\n```\n\n##### Retrieving Analytics Logs\n```javascript\nconst axios = require('axios');\n\nconst url = 'http://127.0.0.1:8000/analytics';\n\naxios.get(url)\n.then(response =\u003e {\n    console.log(response.data);\n})\n.catch(error =\u003e {\n    console.error(error);\n});\n```\n\n### Instructions for Using Dockerfile and Makefile\n\n1. **Build the Docker image**:\n   ```sh\n   make build\n   ```\n\n2. **Run the Docker container**:\n   ```sh\n   make run\n   ```\n\n3. **Stop the Docker container**:\n   ```sh\n   make stop\n   ```\n\n4. **Remove the Docker container**:\n   ```sh\n   make remove\n   ```\n\n5. **Clean Docker images and containers**:\n   ```sh\n   make clean\n   ```\n\n6. **Run tests**:\n   ```sh\n   make test\n   ```\n\n7. **Initialize a Git repository**:\n   ```sh\n   make git-init\n   ```\n\n8. **Check Git status**:\n   ```sh\n   make git-status\n   ```\n\n9. **Push code to Git repository**:\n   ```sh\n    # On windows\n    make push-win\n    # On Linux / Mac\n    make push-lin\n   ```\n\nEnsure that `git-push.sh` is executable by running (Linux/Mac):\n\n```sh\nchmod +x git-push.sh\n```\n\nOn Windows, you can also use `git-push.bat` directly by running:\n\n```cmd\ngit-push.bat\n```\n\n### ChatGPT Prompt\n\nYou can use the following prompt to describe this API to ChatGPT in the future:\n\n```\nI have an Error Logger API that allows sending error logs from various servers and projects to a MongoDB database, with the ability to retrieve logs. The API has the following endpoints:\n- POST /log: Logs an error with fields like project_source, timestamp, error_message, and additional_info. Requires Basic Authentication with username 'admin' and password 'password'.\n- GET /logs: Retrieves all error logs, with optional skip and limit parameters.\n- GET /current: Retrieves all error logs from the current day in Indian Standard Time.\n- GET /analytics: Retrieves analytics logs of all API requests, with optional skip and limit parameters.\nPlease provide usage examples in Python and JavaScript for each endpoint.\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotsooshariff%2Ferror-logger-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnotsooshariff%2Ferror-logger-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotsooshariff%2Ferror-logger-api/lists"}