# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['loralogger',
 'loralogger.config',
 'loralogger.filters',
 'loralogger.handlers',
 'loralogger.loggers']

package_data = \
{'': ['*']}

install_requires = \
['WorkerConnector>=0.0.8,<0.0.9',
 'colorlog>=6.7.0,<7.0.0',
 'python-dotenv>=0.20.0,<0.21.0',
 'redis>=4.3.4,<5.0.0',
 'requests>=2.28.1,<3.0.0']

setup_kwargs = {
    'name': 'loralogger',
    'version': '0.3.7',
    'description': 'Custom logging handler for AskLora projects',
    'long_description': '# LORA Logger\n\nThis package contains both the customised handler for saving the logs into a elasticsearch database, and a factory for creating customised loggers that can use that handler.\n\nThe customised handler will forward the logs to an existing logging service through our own celery service. This logging service will handle the logs and input them into the database. This is done to unionise the logs into a single database.\n\n## Diagram\n\n```mermaid\nflowchart LR\n\n    services["Services\\n<small>All backend projects\\nthat need the logging\\nsystem</small>"]-->producer[[Producer]]\n    subgraph "LoraLogger package"\n    producer-->queue[Queue]\n    end\n    queue-->consumer[[Consumer]]\n    subgraph "AskLora logger service"\n    consumer-->database[(<small>ElasticSearch\\nDatabase</small>)]\n    end\n\n```\n\n## How to use\n\nCurrently, this package exports a logging handler. Loggers with this handler will be automatically send the records to the elasticsearch server set using the environment variable.\n\n### Package installation\n\nthere are two ways to install this pacakge\n\n- install the package locally. first, build the project:\n  ```bash\n  poetry build\n  ```\n  then you can install using pip\n  ```bash\n  pip install /path/to/logger/dist/loralogger-0.3.0-py3-none-any.whl\n  ```\n  or if youre using poetry, use:\n  ```bash\n  poetry add /path/to/logger/dist/loralogger-0.3.0-py3-none-any.tar.gz\n  ```\n- Install the package from pip\n  ```bash\n  pip install loralogger\n  ```\n\n### Using this package\n\nFirst, set these environment variables:\n\n```\n# Set amqp backend\nAMQP_BROKER=localhost\nAMQP_PORT=5672\nAMQP_USER=rabbitmq\nAMQP_PASSWORD=rabbitmq\n\n# set results backend\nREDIS_HOST=localhost\nREDIS_PORT=6379\n\n# set sentinel mode\nREDIS_SENTINEL=False  # or True\n```\n\nThen you can use the logger in two ways:\n\n1. Use dedicated logger instances for specific projects. These will be automatically log to Elasticsearch (i.e. using the ESHandler)\n\n   - import the from loralogger logger factory\n\n   ```python\n   from loralogger import LoggerInstances, LoraLogger\n   ```\n\n   - get the logger instance with the `LoggerInstances` enum as label (preferred), or you can also use other labels by passing a string\n\n     ```python\n     askloraxalpaca_logger = LoraLogger.get_logger(\n        LoggerInstances.ASKLORAXALPACA,\n        log_to_console=True,\n     )\n     ```\n\n   - Use the logger instance\n     ```python\n     askloraxalpaca_logger.info("This works!")\n     ```\n\n2. Use the handler directly to your own logger instance:\n\n   - import the handler\n\n     ```python\n     from loralogger import LogToESHandler\n     ```\n\n   - initialise logging instance\n\n     ```python\n     import logging \n     backend_logger = logging.getLogger("backend")\n     ```\n\n   - Create the handler instance, initialise with the desired LoggerInstances\n\n     ```python\n     logger_instance = LoggerInstances.LEDGER\n     handler = LogToESHandler(logger_instance)\n     ```\n\n   - add the handler instance to the logger\n\n     ```python\n     backend_logger.addHandler(handler)\n     ```\n\n   - And finally, use the logger\n\n     ```python\n     backend_logger.info("This is an info")\n     ```\n\n# Features\n\n- Send your logs to Elasticsearch by setting `send_to_es` argument to `True` when initialising your logger, i.e.\n  ```python\n  logger = LoraLogger.getLogger("backend", log_to_es=True)\n  ```\n- Normally, sending logs to Elasticsearch will use RabbitMQ to not block the running operation, but you can skip it and send the logs directly using Elasticsearch API by setting `skip_queue` argument to `True`:\n  ```python\n  logger = LoraLogger.get_logger(\n    \'ledger\',\n    log_to_es=True,\n    skip_queue=True,\n  )\n  ```\n- You can use `event` and `id` to categorise your logs further in Elasticsearch:\n  ```python\n  logger.info(\'Job started\', event=\'calling-api\', id=\'job-1)\n  ```\n\n# Notes\n\n- if the pip installation fails, check this link https://github.com/celery/librabbitmq/issues/131#issuecomment-661884151\n',
    'author': 'LORA Technologies',
    'author_email': 'asklora@loratechai.com',
    'maintainer': 'None',
    'maintainer_email': 'None',
    'url': 'None',
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'python_requires': '>=3.9,<4.0',
}


setup(**setup_kwargs)
