eox-audit-model


Nameeox-audit-model JSON
Version 5.1.0 PyPI version JSON
download
home_pageNone
SummaryDjango eduNEXT Audit Model
upload_time2024-12-12 20:09:21
maintainerNone
docs_urlNone
authoreduNEXT
requires_pythonNone
licenseAGPL
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ===================
Edunext Audit Model
===================

|Maintainance Badge| |Test Badge| |PyPI Badge|

.. |Maintainance Badge| image:: https://img.shields.io/badge/Status-Maintained-brightgreen
   :alt: Maintainance Status
.. |Test Badge| image:: https://img.shields.io/github/actions/workflow/status/edunext/eox-audit-model/.github%2Fworkflows%2Ftests.yml?label=Test
   :alt: GitHub Actions Workflow Test Status
.. |PyPI Badge| image:: https://img.shields.io/pypi/v/eox-audit-model?label=PyPI
   :alt: PyPI - Version
   
Eox-audit-model is a Django application designed to provide an audit model for tracking and logging changes within the Open edX platform.
This plugin saves information in the database about executed methods, creating a detailed audit trail of various operations. Developed as part of
the Edunext Open edX Extensions (EOX), **eox-audit-model** assists administrators and developers in maintaining comprehensive monitoring and ensuring
better oversight of the platform's activities.

Features
========

- **Detailed Audit Logging**: Capture comprehensive logs of method executions, including parameters, results, and any generated logs.
- **Automatic Traceback Capture**: Automatically log traceback information if an exception occurs during method execution.
- **User Tracking**: Record the user who initiated the method, providing accountability and traceability.
- **Flexible Logging Mechanisms**: Log actions either by directly calling a method or using a decorator for convenience.
- **Customizable Notes**: Add custom notes to logs for additional context and information.
- **Comprehensive Monitoring**: Maintain an extensive audit trail for better monitoring and oversight of platform activities.

Installation
============

1. Install eox-audit-model in Tutor with `OPENEDX_EXTRA_PIP_REQUIREMENTS`` setting in the `config.yml`:

   .. code-block:: yml
      
      OPENEDX_EXTRA_PIP_REQUIREMENTS:
         - eox-audit-model=={{version}}

2. Add eox_audit_model to `INSTALLED_APPS``, you can create a `Tutor plugin <https://docs.tutor.edly.io/tutorials/plugin.html>`_, e.g.:

   .. code-block:: yml
      
      from tutor import hooks

      hooks.Filters.ENV_PATCHES.add_item(
         (
            "openedx-lms-common-settings",
            "settings.INSTALLED_APPS.append('eox_audit_model.apps.EoxAuditModelConfig')"
         )
      )     

3. Save the configuration with ``tutor config save``.

4. Build the image and launch your platform with ``tutor local launch``.

Compatibility notes
-------------------

+------------------+---------------+
| Open edX Release | Version       |
+==================+===============+
| Juniper          | >=0.2, <0.4   |
+------------------+---------------+
| Koa              | >=0.4, <=0.7  |
+------------------+---------------+
| Lilac            | >=0.4, <=0.7  |
+------------------+---------------+
| Maple            | >=0.7, <1.0   |
+------------------+---------------+
| Nutmeg           | >=1.0, <5.0   |
+------------------+---------------+
| Olive            | >=2.0, <5.0   |
+------------------+---------------+
| Palm             | >=3.0, <5.0   |
+------------------+---------------+
| Quince           | >=4.0         |
+------------------+---------------+
| Redwood          | >=4.2.0       |
+------------------+---------------+
| Sumac            | >=5.1.0       |
+------------------+---------------+

Usage
=====

Eox-audit-model can be used to audit any execution of a method or function. This will create a database record with the following information:

- **Status**: If the process was successful or not.
- **Action**: The given string to identify the process.
- **Timestamp**: The execute date.
- **Method name**: Method or function name.
- **Captured log**: Logs generated in the execution.
- **Traceback log**: If there is an exception, this will contain the traceback.
- **Site**: Current site.
- **Performer**: The user who started the method; depends on the *request.user*.
- **Input**: The values used to execute the method.
- **Output**: The value returned by the method.
- **Ip**: Current IP.

There are two primary ways to use the plugin:

Direct Method Call
------------------

You can log an action directly by importing the model and calling the `execute_action` method. This method requires several parameters to log the information:

- `action`: A string describing the action, e.g., `'Add view info'`.
- `method`: The method being executed.
- `parameters`: A dictionary containing positional arguments (`args`) and keyword arguments (`kwargs`).
- `notes`: An optional list of dictionaries for storing custom information.

Example:

.. code-block:: python

  from eox_audit_model.models import AuditModel

  def any_method(parameter1, parameter2, parameter3):
    """Do something"""
    return 'Success'

  def audit_process():
    """Execute audit process"""
    action = "This is a simple action"
    parameters = {
      "args": (2, 6),
      "kwargs": {"parameter3": 9},
    }

    expected_value = AuditModel.execute_action(action, any_method, parameters)
    ...

Using the Decorator
-------------------

The plugin also provides a decorator that can be used to log method executions automatically. The decorator
handles calling the `execute_action` method behind the scenes and saves the information for you.

Example:

.. code-block:: python

  from eox_audit_model.decorators import audit_method

  @audit_method(action="This is a simple action")
  def any_method(parameter1, parameter2, parameter3):
    """Do something"""
    return 'Success'

  def audit_process():
    """Execute audit process"""
    expected_value = any_method(3, 6, 9)
    ...

License
=======

This software is licensed under the terms of the AGPLv3. See the LICENSE file for details.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "eox-audit-model",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "eduNEXT",
    "author_email": "contact@edunext.co",
    "download_url": "https://files.pythonhosted.org/packages/83/b7/9cd8ed0d2dcb703e6b625243a8a352edd32d53cd26c49ed9bf0522be6dc8/eox_audit_model-5.1.0.tar.gz",
    "platform": null,
    "description": "===================\nEdunext Audit Model\n===================\n\n|Maintainance Badge| |Test Badge| |PyPI Badge|\n\n.. |Maintainance Badge| image:: https://img.shields.io/badge/Status-Maintained-brightgreen\n   :alt: Maintainance Status\n.. |Test Badge| image:: https://img.shields.io/github/actions/workflow/status/edunext/eox-audit-model/.github%2Fworkflows%2Ftests.yml?label=Test\n   :alt: GitHub Actions Workflow Test Status\n.. |PyPI Badge| image:: https://img.shields.io/pypi/v/eox-audit-model?label=PyPI\n   :alt: PyPI - Version\n   \nEox-audit-model is a Django application designed to provide an audit model for tracking and logging changes within the Open edX platform.\nThis plugin saves information in the database about executed methods, creating a detailed audit trail of various operations. Developed as part of\nthe Edunext Open edX Extensions (EOX), **eox-audit-model** assists administrators and developers in maintaining comprehensive monitoring and ensuring\nbetter oversight of the platform's activities.\n\nFeatures\n========\n\n- **Detailed Audit Logging**: Capture comprehensive logs of method executions, including parameters, results, and any generated logs.\n- **Automatic Traceback Capture**: Automatically log traceback information if an exception occurs during method execution.\n- **User Tracking**: Record the user who initiated the method, providing accountability and traceability.\n- **Flexible Logging Mechanisms**: Log actions either by directly calling a method or using a decorator for convenience.\n- **Customizable Notes**: Add custom notes to logs for additional context and information.\n- **Comprehensive Monitoring**: Maintain an extensive audit trail for better monitoring and oversight of platform activities.\n\nInstallation\n============\n\n1. Install eox-audit-model in Tutor with `OPENEDX_EXTRA_PIP_REQUIREMENTS`` setting in the `config.yml`:\n\n   .. code-block:: yml\n      \n      OPENEDX_EXTRA_PIP_REQUIREMENTS:\n         - eox-audit-model=={{version}}\n\n2. Add eox_audit_model to `INSTALLED_APPS``, you can create a `Tutor plugin <https://docs.tutor.edly.io/tutorials/plugin.html>`_, e.g.:\n\n   .. code-block:: yml\n      \n      from tutor import hooks\n\n      hooks.Filters.ENV_PATCHES.add_item(\n         (\n            \"openedx-lms-common-settings\",\n            \"settings.INSTALLED_APPS.append('eox_audit_model.apps.EoxAuditModelConfig')\"\n         )\n      )     \n\n3. Save the configuration with ``tutor config save``.\n\n4. Build the image and launch your platform with ``tutor local launch``.\n\nCompatibility notes\n-------------------\n\n+------------------+---------------+\n| Open edX Release | Version       |\n+==================+===============+\n| Juniper          | >=0.2, <0.4   |\n+------------------+---------------+\n| Koa              | >=0.4, <=0.7  |\n+------------------+---------------+\n| Lilac            | >=0.4, <=0.7  |\n+------------------+---------------+\n| Maple            | >=0.7, <1.0   |\n+------------------+---------------+\n| Nutmeg           | >=1.0, <5.0   |\n+------------------+---------------+\n| Olive            | >=2.0, <5.0   |\n+------------------+---------------+\n| Palm             | >=3.0, <5.0   |\n+------------------+---------------+\n| Quince           | >=4.0         |\n+------------------+---------------+\n| Redwood          | >=4.2.0       |\n+------------------+---------------+\n| Sumac            | >=5.1.0       |\n+------------------+---------------+\n\nUsage\n=====\n\nEox-audit-model can be used to audit any execution of a method or function. This will create a database record with the following information:\n\n- **Status**: If the process was successful or not.\n- **Action**: The given string to identify the process.\n- **Timestamp**: The execute date.\n- **Method name**: Method or function name.\n- **Captured log**: Logs generated in the execution.\n- **Traceback log**: If there is an exception, this will contain the traceback.\n- **Site**: Current site.\n- **Performer**: The user who started the method; depends on the *request.user*.\n- **Input**: The values used to execute the method.\n- **Output**: The value returned by the method.\n- **Ip**: Current IP.\n\nThere are two primary ways to use the plugin:\n\nDirect Method Call\n------------------\n\nYou can log an action directly by importing the model and calling the `execute_action` method. This method requires several parameters to log the information:\n\n- `action`: A string describing the action, e.g., `'Add view info'`.\n- `method`: The method being executed.\n- `parameters`: A dictionary containing positional arguments (`args`) and keyword arguments (`kwargs`).\n- `notes`: An optional list of dictionaries for storing custom information.\n\nExample:\n\n.. code-block:: python\n\n  from eox_audit_model.models import AuditModel\n\n  def any_method(parameter1, parameter2, parameter3):\n    \"\"\"Do something\"\"\"\n    return 'Success'\n\n  def audit_process():\n    \"\"\"Execute audit process\"\"\"\n    action = \"This is a simple action\"\n    parameters = {\n      \"args\": (2, 6),\n      \"kwargs\": {\"parameter3\": 9},\n    }\n\n    expected_value = AuditModel.execute_action(action, any_method, parameters)\n    ...\n\nUsing the Decorator\n-------------------\n\nThe plugin also provides a decorator that can be used to log method executions automatically. The decorator\nhandles calling the `execute_action` method behind the scenes and saves the information for you.\n\nExample:\n\n.. code-block:: python\n\n  from eox_audit_model.decorators import audit_method\n\n  @audit_method(action=\"This is a simple action\")\n  def any_method(parameter1, parameter2, parameter3):\n    \"\"\"Do something\"\"\"\n    return 'Success'\n\n  def audit_process():\n    \"\"\"Execute audit process\"\"\"\n    expected_value = any_method(3, 6, 9)\n    ...\n\nLicense\n=======\n\nThis software is licensed under the terms of the AGPLv3. See the LICENSE file for details.\n",
    "bugtrack_url": null,
    "license": "AGPL",
    "summary": "Django eduNEXT Audit Model",
    "version": "5.1.0",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a630ac6cef257530ee5c3a070f923c024c7d1da000e4d336217dd81a57d5918d",
                "md5": "17da09c60fd1b43564789376235b486d",
                "sha256": "430de1b39870dd6a5b0e57fe9047e97ddaa1782411d7f0ef2e0b5c64d7dbfa0c"
            },
            "downloads": -1,
            "filename": "eox_audit_model-5.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "17da09c60fd1b43564789376235b486d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 32117,
            "upload_time": "2024-12-12T20:09:19",
            "upload_time_iso_8601": "2024-12-12T20:09:19.178405Z",
            "url": "https://files.pythonhosted.org/packages/a6/30/ac6cef257530ee5c3a070f923c024c7d1da000e4d336217dd81a57d5918d/eox_audit_model-5.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "83b79cd8ed0d2dcb703e6b625243a8a352edd32d53cd26c49ed9bf0522be6dc8",
                "md5": "4fb270f3a9f5d47af4b4b25d25e6d057",
                "sha256": "8454079aa8659b23aabacd23fa4b741333cbb12c766089a737c7bbd43d7fe581"
            },
            "downloads": -1,
            "filename": "eox_audit_model-5.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "4fb270f3a9f5d47af4b4b25d25e6d057",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 30340,
            "upload_time": "2024-12-12T20:09:21",
            "upload_time_iso_8601": "2024-12-12T20:09:21.270864Z",
            "url": "https://files.pythonhosted.org/packages/83/b7/9cd8ed0d2dcb703e6b625243a8a352edd32d53cd26c49ed9bf0522be6dc8/eox_audit_model-5.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-12 20:09:21",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "eox-audit-model"
}
        
Elapsed time: 0.91224s