{"id":19503639,"url":"https://github.com/im-cloud-spain-connectors/python-connect-devops-logger-adapter","last_synced_at":"2025-02-25T21:44:28.044Z","repository":{"id":78684778,"uuid":"586954712","full_name":"IM-Cloud-Spain-Connectors/python-connect-devops-logger-adapter","owner":"IM-Cloud-Spain-Connectors","description":"Extends the Connect DevOps built-in Logger.","archived":false,"fork":false,"pushed_at":"2023-11-03T13:03:43.000Z","size":29,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-08T10:39:54.870Z","etag":null,"topics":["adapter","component","connect","devops","logger","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IM-Cloud-Spain-Connectors.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-01-09T16:14:02.000Z","updated_at":"2023-06-23T08:06:44.000Z","dependencies_parsed_at":"2023-04-26T10:47:18.688Z","dependency_job_id":"decf4196-86b2-420e-a0df-820bcd872e90","html_url":"https://github.com/IM-Cloud-Spain-Connectors/python-connect-devops-logger-adapter","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IM-Cloud-Spain-Connectors%2Fpython-connect-devops-logger-adapter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IM-Cloud-Spain-Connectors%2Fpython-connect-devops-logger-adapter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IM-Cloud-Spain-Connectors%2Fpython-connect-devops-logger-adapter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IM-Cloud-Spain-Connectors%2Fpython-connect-devops-logger-adapter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IM-Cloud-Spain-Connectors","download_url":"https://codeload.github.com/IM-Cloud-Spain-Connectors/python-connect-devops-logger-adapter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240754295,"owners_count":19852186,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adapter","component","connect","devops","logger","python"],"created_at":"2024-11-10T22:22:26.202Z","updated_at":"2025-02-25T21:44:28.009Z","avatar_url":"https://github.com/IM-Cloud-Spain-Connectors.png","language":"Python","readme":"# Python Connect DevOps Logger Adapter\n\n[![Test](https://github.com/othercodes/python-connect-devops-logger-adapter/actions/workflows/test.yml/badge.svg)](https://github.com/othercodes/python-connect-devops-logger-adapter/actions/workflows/test.yml)\n\nExtended Connect logger adapter that adds extra fields and prepend the request id to each message.\n\n| Field          | Section | Description                                                                            |\n|----------------|---------|----------------------------------------------------------------------------------------|\n| message        | Message | The actual message text.                                                               |\n| request_id     | Message | The id of the request that is being processed.                                         |\n| request_type   | Extra   | Purchase, Cancel, Change, Suspend, Resume, Adjustment, Setup, Update.                  |\n| request_status | Extra   | Pending, Tier-Setup, Draft, Approved, Inquiring, Failed, Scheduled, Revoking, Revoked. |\n| account_id     | Extra   | Built-in. Optional. The Connect customer account id.                                   |\n| account_name   | Extra   | Built-in. Optional. The Connect customer account name.                                 |\n| tier_id        | Extra   | The Tier account id.                                                                   |\n| tier_config_id | Extra   | Optional. The Connect tier config id.                                                  |\n| asset_id       | Extra   | Optional. The Connect assert id.                                                       |\n\n## Installation\n\nThe easiest way to install the Connect DevOps Logger Adapter is to get the latest version from PyPI:\n\n```bash\n# using poetry\npoetry add rndi-connect-devops-logger-adapter\n# using pip\npip install rndi-connect-devops-logger-adapter\n```\n\n## The Contract\n\nThe used interface is the python build-in `logging.LoggerAdapter`.\n\n## The Adapter\n\nThe usage of the adapter is quite easy, you just need to import it and call the `bind_logger` function using the logger\nand the request you want to bind. A new instance of LoggerAdapter will be returned with all the required data attached.\n\n```python\nimport logging\nfrom rndi.connect.devops_logger_adapter.adapter import bind_logger\n\nrequest = {\n    'id': 'PR-1000-2000-3000-4000-001',\n    'type': 'purchase',\n    'status': 'pending'\n    # ...\n}\n\nlogger = bind_logger(logging.getLogger('MyLogger'), request)\n\nlogger.info('Hello world')  # output: PR-1000-2000-3000-4000-001 Hello world\n```\n\nAlternatively, you can use the `WithBoundedLogger` that exposes the `bind_logger` method, this way you can easily bind\nthe logger from your extension.\n\n```python\nfrom logging import LoggerAdapter\nfrom rndi.connect.devops_logger_adapter.mixins import WithBoundedLogger\n\n\nclass SomeBusinessTransaction(WithBoundedLogger):\n    def __init__(self, logger: LoggerAdapter):\n        self.logger = logger\n\n    def process(self, request: dict):\n        self.logger.info('Hello world')  # output: Hello world\n\n        # bind the logger to the request. \n        self.bind_logger(request)\n\n        self.logger.info('Hello world')  # output: PR-1000-2000-3000-4000-001 Hello world\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fim-cloud-spain-connectors%2Fpython-connect-devops-logger-adapter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fim-cloud-spain-connectors%2Fpython-connect-devops-logger-adapter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fim-cloud-spain-connectors%2Fpython-connect-devops-logger-adapter/lists"}