{"id":15021975,"url":"https://github.com/fullstackwithlawrence/secure-logger","last_synced_at":"2026-01-30T08:04:06.710Z","repository":{"id":155422316,"uuid":"632593658","full_name":"FullStackWithLawrence/secure-logger","owner":"FullStackWithLawrence","description":"A Python decorator to generate redacted and nicely formatted log entries","archived":false,"fork":false,"pushed_at":"2025-12-10T01:41:50.000Z","size":539,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-29T19:39:35.295Z","etag":null,"topics":["12-factor","actions","ci","ci-cd","dependabot","flake8","logging","makefile","mergify","pre-commit","pre-commit-hook","prettier","pylint","pypi-package","python","python3","semantic-release","test-automation","tox"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/secure-logger/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FullStackWithLawrence.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"lpm0073","patreon":"FullStackWithLawrence"}},"created_at":"2023-04-25T18:23:08.000Z","updated_at":"2025-11-01T14:58:04.000Z","dependencies_parsed_at":"2023-12-10T18:26:42.690Z","dependency_job_id":"84429ebf-d1db-4090-af4d-28c251a25197","html_url":"https://github.com/FullStackWithLawrence/secure-logger","commit_stats":{"total_commits":326,"total_committers":4,"mean_commits":81.5,"dds":0.3957055214723927,"last_synced_commit":"6fac2678372bb875e0491ab298b62d9b40bf3fdc"},"previous_names":["fullstackwithlawrence/secure-logger","lpm0073/secure-logger"],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/FullStackWithLawrence/secure-logger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FullStackWithLawrence%2Fsecure-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FullStackWithLawrence%2Fsecure-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FullStackWithLawrence%2Fsecure-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FullStackWithLawrence%2Fsecure-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FullStackWithLawrence","download_url":"https://codeload.github.com/FullStackWithLawrence/secure-logger/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FullStackWithLawrence%2Fsecure-logger/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28908852,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-30T06:42:00.998Z","status":"ssl_error","status_checked_at":"2026-01-30T06:41:58.659Z","response_time":66,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["12-factor","actions","ci","ci-cd","dependabot","flake8","logging","makefile","mergify","pre-commit","pre-commit-hook","prettier","pylint","pypi-package","python","python3","semantic-release","test-automation","tox"],"created_at":"2024-09-24T19:57:17.090Z","updated_at":"2026-01-30T08:04:06.661Z","avatar_url":"https://github.com/FullStackWithLawrence.png","language":"Python","funding_links":["https://github.com/sponsors/lpm0073","https://patreon.com/FullStackWithLawrence"],"categories":[],"sub_categories":[],"readme":"# Secure Logger\n\n[![FullStackWithLawrence](https://a11ybadges.com/badge?text=FullStackWithLawrence\u0026badgeColor=orange\u0026logo=youtube\u0026logoColor=282828)](https://www.youtube.com/@FullStackWithLawrence)\n[![Python](https://a11ybadges.com/badge?logo=python)](https://www.python.org/)\u003cbr\u003e\n[![12-Factor](https://img.shields.io/badge/12--Factor-Compliant-green.svg)](./doc/Twelve_Factor_Methodology.md)\n[![Unit Tests](https://github.com/FullStackWithLawrence/secure-logger/actions/workflows/tests.yml/badge.svg)](https://github.com/FullStackWithLawrence/secure-logger/actions)\n![GHA pushMain Status](https://img.shields.io/github/actions/workflow/status/FullStackWithLawrence/secure-logger/pushMain.yml?branch=main)\n![Auto Assign](https://github.com/FullStackwithLawrence/secure-logger/actions/workflows/auto-assign.yml/badge.svg)[![Source\ncode](https://img.shields.io/static/v1?logo=github\u0026label=Git\u0026style=flat-square\u0026color=orange\u0026message=Source%20code)](https://github.com/FullStackWithLawrence/secure-logger)\n[![Release Notes](https://img.shields.io/github/release/FullStackWithLawrence/secure-logger)](https://github.com/FullStackWithLawrence/secure-logger/releases)\n[![PyPI\nreleases](https://img.shields.io/pypi/v/secure-logger?logo=python\u0026logoColor=white)](https://pypi.org/project/secure-logger)\n[![License: AGPL\nv3](https://img.shields.io/badge/License-AGPL_v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)\n[![hack.d Lawrence\nMcDaniel](https://img.shields.io/badge/hack.d-Lawrence%20McDaniel-orange.svg)](https://lawrencemcdaniel.com)\n\nA Python decorator to generate redacted and nicely formatted log\nentries. Works on all callables: class, class methods, Python module\nfunctions. Recursively redacts Python dictionary key values based on a\ncustomizable list of case-insensitive keys. Prevents your sensitive\napplication data like cloud provider key-pairs from leaking into your\napplication logs.\n\n## Installation\n\n```bash\npip install secure-logger\n```\n\n## Usage\n\n### As a decorator\n\n```python\nfrom secure_logger.decorators import secure_logger\nimport logging\n\nlogging.getLogger(__name__)\nlogging.basicConfig(level=logging.INFO)\n\nclass Foo(object):\n    @secure_logger(log_level='INFO')\n    def bar(self, dict_data, list_data):\n        pass\n\n# call your method, passing some sensitive data\ndict_data = {\n    \"not_a_sensitive_key\": \"you-can-see-me\",\n    \"aws-access-key-id\": \"i-am-hidden\",\n    \"aws-secret-access-key\": \"so-am-i\",\n}\nlist_data = [\"foo\", \"bar\"]\nfoo = Foo()\nfoo.bar(dict_data=dict_data, list_data=list_data)\n```\n\nLog output:\n\n```console\nINFO:secure_logger: __main__.bar() ['\u003c__main__.Foo object at 0x103474ac0\u003e'] keyword args: {\n    \"dict_data\": {\n        \"not_a_sensitive_key\": \"you-can-see-me\",\n        \"aws-access-key-id\": \"*** -- secure_logger() -- ***\",\n        \"aws-secret-access-key\": \"*** -- secure_logger() -- ***\"\n    },\n    \"list_data\": [\n        \"foo\",\n        \"bar\"\n    ]\n```\n\n### As library functions\n\n```python\nfrom secure_logger.masked_dict import masked_dict, masked_dict2str\n\ndict_data = {\n    'not_a_sensitive_key': 'you-can-see-me',\n    'aws-access-key_id': conf.AWS_ACCESS_KEY_ID,\n    'aws-secret-access-key': conf.AWS_SECRET_ACCESS_KEY\n}\nprint(masked_dict2str(dict_data))\n```\n\nOutput:\n\n```bash\n{\n    \"not_a_sensitive_key\": \"you-can-see-me\",\n    \"aws-access-key-id\": \"*** -- secure_logger() -- ***\",\n    \"aws-secret-access-key\": \"*** -- secure_logger() -- ***\"\n}\n```\n\n## Configuration\n\nsecure_logger accepts optional parameters which you can configure as either bash environment variables or with a .env file placed in the root of your project\n\n- **SECURE_LOGGER_SENSITIVE_KEYS**: a Python list of dictionary keys. Not case sensitive.\n- **SECURE_LOGGER_REDACTION_MESSAGE**: a string value that will replace the sensitive key values\n- **SECURE_LOGGER_INDENTATION**: number of characters to indent JSON string output when logging output\n- **SECURE_LOGGER_LOG_LEVEL**: the level at which secure_logger generates log entries. One of: 'CRITICAL', 'FATAL', 'ERROR', 'WARN', 'WARNING', 'INFO', 'DEBUG'\n\nAdditionally, you can override individual invocations of the decorator with custom parameters:\n\n```python\nclass MyClass():\n\n    @secure_logger(log_level='DEBUG', sensitive_keys=[\"password\", \"apikey\", \"crown_jewels\"], message=\"*** -- TOP SECRET -- ***\", indent=4)\n    def another_function(self, password: str, apikey: str, crown_jewels: List(dict)):\n         pass\n```\n\n## Configuration Defaults\n\n```python\nSECURE_LOGGER_REDACTION_MESSAGE = \"*** -- secure_logger() -- ***\"\nSECURE_LOGGER_INDENTATION = 4\nSECURE_LOGGER_SENSITIVE_KEYS = [\n    \"password\",\n    \"token\",\n    \"client_id\",\n    \"client_secret\",\n    \"Authorization\",\n    \"secret\",\n    \"access_key_id\",\n    \"secret_access_key\",\n    \"access-key-id\",\n    \"secret-access-key\",\n    \"aws_access_key_id\",\n    \"aws_secret_access_key\",\n    \"aws-access-key-id\",\n    \"aws-secret-access-key\",\n]\nSECURE_LOGGER_LOG_LEVEL = 'DEBUG'\n```\n\n## Contributing\n\nPull requests are welcomed and encouraged!\n\n- This project uses an automated [Pull Request](.github/workflows/pullRequestController.yml) CI/CD process.\n- This project conforms to [12-Factor Methodology](./doc/Twelve_Factor_Methodology.md).\n- This project uses [Semantic Versioning](./doc/SEMANTIC_VERSIONING.md) which requires that git commit messages follow strict (but easy to learn) formatting rules.\n\nContact: [Lawrence McDaniel](https://lawrencemcdaniel.com/contact).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffullstackwithlawrence%2Fsecure-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffullstackwithlawrence%2Fsecure-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffullstackwithlawrence%2Fsecure-logger/lists"}