Skip to content

Commit

Permalink
Merge pull request #57 from MEHRSHAD-MIRSHEKARY/refactor/docs
Browse files Browse the repository at this point in the history
Refactor/docs
  • Loading branch information
ARYAN-NIKNEZHAD authored Aug 30, 2024
2 parents 6c3abcc + 025877d commit 0390ee0
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 24 deletions.
29 changes: 29 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version, and other tools
build:
os: ubuntu-22.04
tools:
python: "3.8"

# Build documentation with Sphinx
sphinx:
configuration: docs/conf.py

# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub


# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: packages/requirements-dev.txt
21 changes: 9 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The [`django_logging`](https://github.com/ARYAN-NIKNEZHAD/django_logging) is a D

- Language: Python > 3.8
- Framework: Django > 4.2
|
-

## Documentation

Expand Down Expand Up @@ -77,7 +77,7 @@ Email notifier enabled: False.
```


That's it! `django_logging` is ready to use with default settings. For further customization, refer to the Settings section
That's it! `django_logging` is ready to use with default settings. For further customization, refer to the [Settings](#settings) section


## Usage
Expand All @@ -97,8 +97,10 @@ logger.error("This is an error message")
logger.critical("This is a critical message")
```
These logs will be handled according to the configurations set up by `django_logging`, using either the default settings or any custom settings you've provided.
Request Logging Middleware
To log request information such as the request path, user, IP address, and user agent, add `django_logging`.middleware.RequestLogMiddleware to your MIDDLEWARE setting:

2. **Request Logging Middleware**

To log the detail of each request to the server and capture information such as the request path, user, IP address, and user agent, add `django_logging.middleware.RequestLogMiddleware` to your MIDDLEWARE setting:

```python
MIDDLEWARE = [
Expand All @@ -108,7 +110,7 @@ MIDDLEWARE = [
]
```

This middleware will log request details at info level, here is an example with default format:
This middleware will log th request details at info level, here is an example with default format:
```shell
INFO | 'datetime' | django_logging | Request Info: (request_path: /example-path, user: example_user,
IP: 192.168.1.1, user_agent: Mozilla/5.0)
Expand Down Expand Up @@ -150,7 +152,7 @@ logger = logging.getLogger(__name__)

log_and_notify_admin(logger, logging.INFO, "This is a log message")
```
You can also include additional request information in the email by passing an `extra` dictionary:
You can also include additional request information (`ip_address` and `browser_type`) in the email by passing an `extra` dictionary:
```python
from django_logging.utils.log_email_notifier.log_and_notify import log_and_notify_admin
import logging
Expand Down Expand Up @@ -183,12 +185,7 @@ This command will attach the log directory and send a zip file to the provided e

## Settings

The `DJANGO_LOGGING` configuration allows you to customize various aspects of logging within your Django project. Below is a detailed description of each configurable option.

**Configuration Options**
The settings are defined in the `DJANGO_LOGGING` dictionary in your
`settings.py` file. Here’s a breakdown of each option:
By default, `django_logging` uses a built-in configuration that requires no additional setup. However, you can customize the logging settings by adding a `DJANGO_LOGGING` configuration to your Django settings file.
By default, `django_logging` uses a built-in configuration that requires no additional setup. However, you can customize the logging settings by adding the `DJANGO_LOGGING` dictionary configuration to your Django `settings` file.

Example configuration:
```python
Expand Down
11 changes: 1 addition & 10 deletions docs/settings.rst
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
Settings
========

The `DJANGO_LOGGING` configuration allows you to customize various aspects of logging within your Django project. Below is a detailed description of each configurable option.

Configuration Options
----------------------

The settings are defined in the `DJANGO_LOGGING` dictionary in your `settings.py` file. Here’s a breakdown of each option:



By default, `django_logging` uses a built-in configuration that requires no additional setup. However, you can customize the logging settings by adding a `DJANGO_LOGGING` configuration to your Django settings file.
By default, `django_logging` uses a built-in configuration that requires no additional setup. However, you can customize the logging settings by adding the `DJANGO_LOGGING` dictionary configuration to your Django `settings` file.

Example configuration:

Expand Down
4 changes: 2 additions & 2 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Once `django_logging` is installed and added to your `INSTALLED_APPS`, you can s

2. **Request Logging Middleware**

To log request information such as the request path, user, IP address, and user agent, add `django_logging.middleware.RequestLogMiddleware` to your `MIDDLEWARE` setting:
To capture and log information of each request to the server, such as the request path, user, IP address, and user agent, add `django_logging.middleware.RequestLogMiddleware` to your `MIDDLEWARE` setting:

.. code-block:: python
Expand All @@ -33,7 +33,7 @@ Once `django_logging` is installed and added to your `INSTALLED_APPS`, you can s
...
]
This middleware will log request details at info level, here is an example with default format:
This middleware will log the request details at info level, here is an example with default format:

.. code-block:: text
Expand Down

0 comments on commit 0390ee0

Please sign in to comment.