Skip to content

Commit

Permalink
Merge pull request #75 from MEHRSHAD-MIRSHEKARY/refactor/docs
Browse files Browse the repository at this point in the history
⚑ πŸ“š πŸ”¨  refactor(docs): Update readme & rst files
ARYAN-NIKNEZHAD authored Sep 2, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 23637e7 + dfcc9e0 commit d79fa24
Showing 7 changed files with 58 additions and 53 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -3,10 +3,10 @@
The [`django_logging`](https://github.com/ARYAN-NIKNEZHAD/django_logging) is a Django package designed to extend and enhance Python’s built-in logging capabilities. By providing customizable configurations and advanced features, it offers developers a comprehensive logging solution tailored specifically for Django applications.

![License](https://img.shields.io/github/license/ARYAN-NIKNEZHAD/django_logging)
![PyPI release](https://img.shields.io/pypi/v/django_logging)
![Supported Python versions](https://img.shields.io/pypi/pyversions/django_logging)
![Supported Django versions](https://img.shields.io/pypi/djversions/django_logging)
![Documentation](https://img.shields.io/readthedocs/django_logging)
![PyPI release](https://img.shields.io/pypi/v/dj-logging)
![Supported Python versions](https://img.shields.io/pypi/pyversions/dj-logging)
![Supported Django versions](https://img.shields.io/pypi/djversions/dj-logging)
![Documentation](https://img.shields.io/readthedocs/django-logging)
![Last Commit](https://img.shields.io/github/last-commit/ARYAN-NIKNEZHAD/django_logging)
![Languages](https://img.shields.io/github/languages/top/ARYAN-NIKNEZHAD/django_logging)
![CI Workflow](https://github.com/ARYAN-NIKNEZHAD/django_logging/actions/workflows/ci.yml/badge.svg)
@@ -40,7 +40,7 @@ Getting started with `django_logging` is simple. Follow these steps to get up an
first, Install `django_logging` via pip:

```shell
$ pip install django_logging
$ pip install dj-logging
```

2. **Add to Installed Apps**
2 changes: 1 addition & 1 deletion docs/contributing.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Contributing to django_logging
Contributing
==============================

We’re excited that you’re interested in contributing to `django_logging`! Whether you’re fixing a bug, adding a feature, or improving the project, your help is appreciated.
18 changes: 9 additions & 9 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -9,20 +9,20 @@ Welcome to django_logging Documentation!
:target: https://github.com/ARYAN-NIKNEZHAD/django_logging/blob/main/LICENSE
:alt: License

.. image:: https://img.shields.io/pypi/v/django_logging
:target: https://pypi.org/project/django_logging/
.. image:: https://img.shields.io/pypi/v/dj-logging
:target: https://pypi.org/project/dj-logging/
:alt: PyPI release

.. image:: https://img.shields.io/pypi/pyversions/django_logging
:target: https://pypi.org/project/django_logging/
.. image:: https://img.shields.io/pypi/pyversions/dj-logging
:target: https://pypi.org/project/dj-logging/
:alt: Supported Python versions

.. image:: https://img.shields.io/pypi/djversions/django_logging
:target: https://pypi.org/project/django_logging/
.. image:: https://img.shields.io/pypi/djversions/dj-logging
:target: https://pypi.org/project/dj-logging/
:alt: Supported Django versions

.. image:: https://img.shields.io/readthedocs/django_logging
:target: https://django_logging.readthedocs.io/en/latest/
.. image:: https://img.shields.io/readthedocs/django-logging
:target: https://django-logging.readthedocs.io/en/latest/
:alt: Documentation

.. image:: https://img.shields.io/github/last-commit/ARYAN-NIKNEZHAD/django_logging
@@ -37,7 +37,7 @@ Welcome to django_logging Documentation!
:target: https://github.com/ARYAN-NIKNEZHAD/django_logging/issues
:alt: Open Issues

.. image:: https://codecov.io/gh/ARYAN-NIKNEZHAD/django_logging/branch/main/graph/badge.svg
.. image:: https://img.shields.io/codecov/c/github/ARYAN-NIKNEZHAD/django_logging/main
:target: https://codecov.io/gh/ARYAN-NIKNEZHAD/django_logging
:alt: Coverage

2 changes: 1 addition & 1 deletion docs/quick_start.rst
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ Getting Started with `django_logging` is simple. Follow these steps to get up an

.. code-block:: shell
$ pip install django_logging
$ pip install dj-logging
2. **Add to Installed Apps**

60 changes: 31 additions & 29 deletions docs/settings.rst
Original file line number Diff line number Diff line change
@@ -3,34 +3,36 @@ Settings

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:

.. code-block:: python
DJANGO_LOGGING = {
"AUTO_INITIALIZATION_ENABLE": True,
"INITIALIZATION_MESSAGE_ENABLE": True,
"LOG_FILE_LEVELS": ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
"LOG_DIR": "logs",
"LOG_FILE_FORMATS": {
"DEBUG": 1,
"INFO": 1,
"WARNING": 1,
"ERROR": 1,
"CRITICAL": 1,
},
"LOG_CONSOLE_LEVEL": "DEBUG",
"LOG_CONSOLE_FORMAT": 1,
"LOG_CONSOLE_COLORIZE": True,
"LOG_DATE_FORMAT": "%Y-%m-%d %H:%M:%S",
"LOG_EMAIL_NOTIFIER": {
"ENABLE": False,
"NOTIFY_ERROR": False,
"NOTIFY_CRITICAL": False,
"LOG_FORMAT": 1,
"USE_TEMPLATE": True,
},
}
Example configuration
---------------------
here is an example of DJANGO_LOGGING in project settings:

.. code-block:: python
DJANGO_LOGGING = {
"AUTO_INITIALIZATION_ENABLE": True,
"INITIALIZATION_MESSAGE_ENABLE": True,
"LOG_FILE_LEVELS": ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
"LOG_DIR": "logs",
"LOG_FILE_FORMATS": {
"DEBUG": 1,
"INFO": 1,
"WARNING": 1,
"ERROR": 1,
"CRITICAL": 1,
},
"LOG_CONSOLE_LEVEL": "DEBUG",
"LOG_CONSOLE_FORMAT": 1,
"LOG_CONSOLE_COLORIZE": True,
"LOG_DATE_FORMAT": "%Y-%m-%d %H:%M:%S",
"LOG_EMAIL_NOTIFIER": {
"ENABLE": False,
"NOTIFY_ERROR": False,
"NOTIFY_CRITICAL": False,
"LOG_FORMAT": 1,
"USE_TEMPLATE": True,
},
}
Here's a breakdown of the available configuration options:
@@ -69,7 +71,7 @@ Here's a breakdown of the available configuration options:


Available Format Options
=========================
------------------------

The `django_logging` package provides predefined log format options that you can use in configuration. These options can be applied to log formats. Below are the available format options:

16 changes: 10 additions & 6 deletions docs/usage.rst
Original file line number Diff line number Diff line change
@@ -3,7 +3,8 @@ Usage

Once `django_logging` is installed and added to your `INSTALLED_APPS`, you can start using it right away. The package provides several features to customize and enhance logging in your Django project. Below is a guide on how to use the various features provided by `django_logging`.

1. **Basic Logging Usage**
Basic Logging Usage
-------------------

At its core, `django_logging` is built on top of Python’s built-in logging module. This means you can use the standard logging module to log messages across your Django project. Here’s a basic example of logging usage:

@@ -21,7 +22,8 @@ Once `django_logging` is installed and added to your `INSTALLED_APPS`, you can s
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.

2. **Request Logging Middleware**
Request Logging Middleware
--------------------------

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:

@@ -40,8 +42,8 @@ Once `django_logging` is installed and added to your `INSTALLED_APPS`, you can s
INFO | 'datetime' | django_logging | Request Info: (request_path: /example-path, user: example_user,
IP: 192.168.1.1, user_agent: Mozilla/5.0)
3. **Context Manager**

Context Manager
---------------
You can use the `config_setup` context manager to temporarily apply `django_logging` configurations within a specific block of code.

Example usage:
@@ -69,7 +71,8 @@ Once `django_logging` is installed and added to your `INSTALLED_APPS`, you can s
"You must set 'AUTO_INITIALIZATION_ENABLE' to False in DJANGO_LOGGING in your settings to use the context manager."
4. **Log and Notify Utility**
Log and Notify Utility
----------------------

To send specific logs as email, use the `log_and_notify_admin` function. Ensure that the `ENABLE` option in `LOG_EMAIL_NOTIFIER` is sent to `True` in your settings:

@@ -106,7 +109,8 @@ Once `django_logging` is installed and added to your `INSTALLED_APPS`, you can s
Additionally, ensure that all required email settings are configured in your Django settings file.
- **Note**: For more detailed configuration options, refer to the [Settings](settings.rst) section.

5. **Send Logs Command**
Send Logs Command
-----------------

To send the entire log directory to a specified email address, use the `send_logs` management command:

3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@ authors = [ "ARYAN-NIKNEZHAD <[email protected]>", "MEHRSHAD-MIRSHEKARY <meh
license = "MIT"
readme = "README.md"
keywords = [ "django_logging", "django", "logging" ]
repository = "https://github.com/ARYAN-NIKNEZHAD/django_logging"

classifiers = [
"Development Status :: 3 - Alpha",
@@ -38,7 +37,7 @@ packages = [
]

[tool.poetry.urls]
"Documentation" = "https://django_logging.readthedocs.io"
"Documentation" = "https://django-logging.readthedocs.io"
"Source Code" = "https://github.com/ARYAN-NIKNEZHAD/django_logging"
"Issues" = "https://github.com/ARYAN-NIKNEZHAD/django_logging/issues"

0 comments on commit d79fa24

Please sign in to comment.