infi-logger


Nameinfi-logger JSON
Version 0.0.7 PyPI version JSON
download
home_page
SummaryLogger package for infinity team
upload_time2023-12-19 12:28:29
maintainer
docs_urlNone
authorInfinity Team
requires_python
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # infinity-elastic-logs

This project is a Python logging library that integrates with Elasticsearch for centralized logging. It provides a simple and convenient way to send logs to Elasticsearch with different log levels.

## Installation

 [The binary installation file](dist/infi_logger-1.0-py3-none-any.whl) attached to this repository should be taken,
Attach to the project where it will be used
and install with:

```bash
pip install path_to_this_project/dist/infi_logger-1.0-py3-none-any.whl
```

Alternatively, you can move in cmd to this project and just write in

```bash
pip install .
```

Replace path_to_this_project with the path where the file is located in your project.

## Usage

To use the logging library, follow these steps:

1. Import the `ElasticLogger` class:

    ```python
   from infi_logger import ElasticLogger
    ```

2. Create an instance of the ElasticLogger class, providing a service name, host, cert_fingerprint, name and password:
   
   ```python
    HOST = "${Ip:Port}"
    CERT_FINGERPRINT = "${fingerprint}"
    NAME = "${Username}" 
    PASSWORD = "${Password}"
    INDEX = "${IndexName}"  # Replace with the index you want to work with

    # logger = ElasticLogger("my-service")
    logger = ElasticLogger("elastic-service", HOST, CERT_FINGERPRINT, NAME, PASSWORD, INDEX)

    ```
   Alternatively, you can create an instance of the ElasticLogger class that will not connect Elastic, providing a service name only:

    ```python
    logger = ElasticLogger("my-service")
    ```
   

3. Use the different log levels to send logs:

   ```python
    logger.debug("This is a debug log")
    logger.info("This is an info log")
    logger.warning("This is a warning log")
    logger.error("This is an error log")
    logger.critical("This is a critical log")
    ```

## Configuration


1. **Elasticsearch Connection**

    The ElasticsearchConnection class handles the connection to Elasticsearch. Ensure that the environment variables mentioned above are correctly set before running the project. The connect_elasticsearch method establishes a connection to Elasticsearch using the provided credentials. If the connection fails, an exception will be raised.

2. **Log Format**

   The logs sent to Elasticsearch have the following format:

   ```json
   {
    "timestamp": "<current_timestamp>",
    "message": "<log_message>",
    "level": "<log_level>",
    "service": "<service_name>"
    }
    ```

3. **Environment Variables**

    You can set the location of log files in case Elastic failed/not connected by setting global environment of "LOG_FILE".
    If not chosen, it will default to "logs/log.log" in your current directory

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "infi-logger",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Infinity Team",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/ba/cb/27f5b95536f85643ca8477c0383e8cf31880389e64cd612ae049fffb5712/infi_logger-0.0.7.tar.gz",
    "platform": null,
    "description": "# infinity-elastic-logs\r\n\r\nThis project is a Python logging library that integrates with Elasticsearch for centralized logging. It provides a simple and convenient way to send logs to Elasticsearch with different log levels.\r\n\r\n## Installation\r\n\r\n [The binary installation file](dist/infi_logger-1.0-py3-none-any.whl) attached to this repository should be taken,\r\nAttach to the project where it will be used\r\nand install with:\r\n\r\n```bash\r\npip install path_to_this_project/dist/infi_logger-1.0-py3-none-any.whl\r\n```\r\n\r\nAlternatively, you can move in cmd to this project and just write in\r\n\r\n```bash\r\npip install .\r\n```\r\n\r\nReplace path_to_this_project with the path where the file is located in your project.\r\n\r\n## Usage\r\n\r\nTo use the logging library, follow these steps:\r\n\r\n1. Import the `ElasticLogger` class:\r\n\r\n    ```python\r\n   from infi_logger import ElasticLogger\r\n    ```\r\n\r\n2. Create an instance of the ElasticLogger class, providing a service name, host, cert_fingerprint, name and password:\r\n   \r\n   ```python\r\n    HOST = \"${Ip:Port}\"\r\n    CERT_FINGERPRINT = \"${fingerprint}\"\r\n    NAME = \"${Username}\" \r\n    PASSWORD = \"${Password}\"\r\n    INDEX = \"${IndexName}\"  # Replace with the index you want to work with\r\n\r\n    # logger = ElasticLogger(\"my-service\")\r\n    logger = ElasticLogger(\"elastic-service\", HOST, CERT_FINGERPRINT, NAME, PASSWORD, INDEX)\r\n\r\n    ```\r\n   Alternatively, you can create an instance of the ElasticLogger class that will not connect Elastic, providing a service name only:\r\n\r\n    ```python\r\n    logger = ElasticLogger(\"my-service\")\r\n    ```\r\n   \r\n\r\n3. Use the different log levels to send logs:\r\n\r\n   ```python\r\n    logger.debug(\"This is a debug log\")\r\n    logger.info(\"This is an info log\")\r\n    logger.warning(\"This is a warning log\")\r\n    logger.error(\"This is an error log\")\r\n    logger.critical(\"This is a critical log\")\r\n    ```\r\n\r\n## Configuration\r\n\r\n\r\n1. **Elasticsearch Connection**\r\n\r\n    The ElasticsearchConnection class handles the connection to Elasticsearch. Ensure that the environment variables mentioned above are correctly set before running the project. The connect_elasticsearch method establishes a connection to Elasticsearch using the provided credentials. If the connection fails, an exception will be raised.\r\n\r\n2. **Log Format**\r\n\r\n   The logs sent to Elasticsearch have the following format:\r\n\r\n   ```json\r\n   {\r\n    \"timestamp\": \"<current_timestamp>\",\r\n    \"message\": \"<log_message>\",\r\n    \"level\": \"<log_level>\",\r\n    \"service\": \"<service_name>\"\r\n    }\r\n    ```\r\n\r\n3. **Environment Variables**\r\n\r\n    You can set the location of log files in case Elastic failed/not connected by setting global environment of \"LOG_FILE\".\r\n    If not chosen, it will default to \"logs/log.log\" in your current directory\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Logger package for infinity team",
    "version": "0.0.7",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e9a275ab7a2b7f57d1d8e9b99e86d5313deda7fbe483508f65570d554f9fad1f",
                "md5": "6c046ab2e2633890e3ca03a7b432d7c8",
                "sha256": "c2b4ccdae85dda7717c10e4f6ad500ac5a3e87fdaf4db0727675b8a6b668d901"
            },
            "downloads": -1,
            "filename": "infi_logger-0.0.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6c046ab2e2633890e3ca03a7b432d7c8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 9672,
            "upload_time": "2023-12-19T12:28:28",
            "upload_time_iso_8601": "2023-12-19T12:28:28.017782Z",
            "url": "https://files.pythonhosted.org/packages/e9/a2/75ab7a2b7f57d1d8e9b99e86d5313deda7fbe483508f65570d554f9fad1f/infi_logger-0.0.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bacb27f5b95536f85643ca8477c0383e8cf31880389e64cd612ae049fffb5712",
                "md5": "522eb0480e87ee1c120f8e195b8fd780",
                "sha256": "bd2018e62a43796f8e9db5113e76bf4f1937b66e025116add66e203704cbbb22"
            },
            "downloads": -1,
            "filename": "infi_logger-0.0.7.tar.gz",
            "has_sig": false,
            "md5_digest": "522eb0480e87ee1c120f8e195b8fd780",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 9569,
            "upload_time": "2023-12-19T12:28:29",
            "upload_time_iso_8601": "2023-12-19T12:28:29.130371Z",
            "url": "https://files.pythonhosted.org/packages/ba/cb/27f5b95536f85643ca8477c0383e8cf31880389e64cd612ae049fffb5712/infi_logger-0.0.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-19 12:28:29",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "infi-logger"
}
        
Elapsed time: 0.14879s