Skip to content

Commit 04dda07

Browse files
committed
new version released: 1.0.4
1 parent 46d4032 commit 04dda07

File tree

4 files changed

+95
-173
lines changed

4 files changed

+95
-173
lines changed

README.md

Lines changed: 94 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,101 @@
11
# Elasticsearch Logger Middleware for FastAPI
22

3-
This middleware enables logging of requests and responses to Elasticsearch in a FastAPI application. It provides detailed logs including request method, URL path, query parameters, request and response headers, status code, and response body.
3+
Elasticsearch Logger Middleware for FastAPI is designed to facilitate detailed and efficient logging directly to Elasticsearch servers from FastAPI applications. It streamlines the logging processes by capturing detailed HTTP requests data and automates telemetry to provide insights into application performance.
44

5-
## Installation
5+
### Key Features
66

7-
You can install the middleware via pip:
7+
1. **Elasticsearch Integration:** Send logs directly to an Elasticsearch server.
8+
2. **Flexible Configuration:** Configure to suit various environment needs.
9+
3. **Automated Detailed Data Logging:** Automatically captures headers, query parameters, and the request body.
10+
4. **Effortless Telemetry:** Automatically generates telemetry for monitoring request times.
11+
5. **Enhanced Data Control:** Limit payload sizes for efficient Elasticsearch indexing.
12+
13+
### Installation
14+
15+
To install this middleware, ensure you have Python installed and then run:
816

917
```bash
1018
pip install fastapi-elasticsearch-middleware
19+
```
20+
21+
### Usage
22+
23+
Configure the middleware by creating a `config` dictionary in your FastAPI application as follows:
24+
25+
```python
26+
config = {
27+
'url': 'http://localhost:9200',
28+
'user': 'elasticsearch_user',
29+
'password': 'password',
30+
'index': 'my_app_logs',
31+
'environment': 'development',
32+
'limit': True,
33+
'debug': False
34+
}
35+
```
36+
37+
**The `debug` parameter prevents sending logs to Elasticsearch.**
38+
39+
Integrate the middleware into your FastAPI application like this:
40+
41+
```python
42+
from fastapi import FastAPI
43+
from my_middleware import ElasticsearchLoggerMiddleware
44+
45+
app = FastAPI()
46+
app.add_middleware(ElasticsearchLoggerMiddleware, config=config)
47+
```
48+
49+
### How It Works
50+
51+
The middleware captures each HTTP request, processes it, and sends log data to your Elasticsearch server based on the configured parameters. It includes detailed logs of request headers, body data, and response metrics.
52+
53+
54+
## How to Contribute
55+
56+
We welcome contributions from the community and are pleased to have you join us. Here are some guidelines that will help you get started.
57+
58+
### Prerequisites
59+
60+
Before contributing, please ensure you have the following:
61+
- A basic understanding of Python and FastAPI.
62+
- A basic understanding of Middlewares.
63+
64+
### Setting Up Your Development Environment
65+
66+
1. **Fork the Repository**: Start by forking the repository to your GitHub account.
67+
2. **Clone the Repository**: Clone your fork to your local machine.
68+
```bash
69+
git clone https://github.com/your-username/repository-name.git
70+
cd repository-name
71+
```
72+
3. **Install Dependencies**: Install the required dependencies.
73+
```bash
74+
pip install -r requirements.txt
75+
```
76+
77+
### Making Changes
78+
79+
1. **Create a New Branch**: Create a new branch for your feature or bug fix.
80+
```bash
81+
git checkout -b awesome-feature
82+
```
83+
2. **Make Your Changes**: Implement your feature or fix a bug. Be sure to adhere to the coding standards and include comments where necessary.
84+
85+
### Submitting a Pull Request
86+
87+
1. **Commit Your Changes**: Once your tests pass, commit your changes.
88+
```bash
89+
git commit -m 'Add some feature'
90+
```
91+
2. **Push to GitHub**: Push your changes to your fork on GitHub.
92+
```bash
93+
git push origin awesome-feature
94+
```
95+
3. **Open a Pull Request**: Go to the original repository and click the *Compare & pull request* button. Then submit your pull request with a clear title and description.
96+
97+
### Code Review
98+
99+
Once your pull request is opened, it will be reviewed by the maintainers. Some changes may be requested. Please be patient and responsive. Once the pull request has been approved, it will be merged into the master branch.
100+
101+
Thank you for contributing!

build/lib/fastapi_elasticsearch_middleware/__init__.py

Whitespace-only changes.

build/lib/fastapi_elasticsearch_middleware/elasticsearch_middleware.py

Lines changed: 0 additions & 169 deletions
This file was deleted.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='fastapi_elasticsearch_middleware',
5-
version='1.0.3',
5+
version='1.0.4',
66
url='https://github.com/GGontijo/fastapi-elasticsearch-middleware.git',
77
description='Elasticsearch Logger Middleware for FastAPI',
88
long_description_content_type='text/markdown',

0 commit comments

Comments
 (0)