{"id":16994489,"url":"https://github.com/thep0y/python-logger","last_synced_at":"2026-02-18T13:02:24.836Z","repository":{"id":62563681,"uuid":"369426842","full_name":"thep0y/python-logger","owner":"thep0y","description":"Colorful logger for python3","archived":false,"fork":false,"pushed_at":"2026-01-17T06:24:03.000Z","size":78,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-17T17:55:31.556Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thep0y.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-21T05:48:31.000Z","updated_at":"2026-01-17T06:22:20.000Z","dependencies_parsed_at":"2023-10-16T17:07:35.083Z","dependency_job_id":null,"html_url":"https://github.com/thep0y/python-logger","commit_stats":null,"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"purl":"pkg:github/thep0y/python-logger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thep0y%2Fpython-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thep0y%2Fpython-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thep0y%2Fpython-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thep0y%2Fpython-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thep0y","download_url":"https://codeload.github.com/thep0y/python-logger/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thep0y%2Fpython-logger/sbom","scorecard":{"id":879685,"data":{"date":"2025-08-11","repo":{"name":"github.com/thep0y/python-logger","commit":"5f33dd54c4353ddcc571e52fd272f926563c462f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.6,"checks":[{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/publish.yaml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":2,"reason":"dependency not pinned by hash detected -- score normalized to 2","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yaml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/thep0y/python-logger/publish.yaml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yaml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/thep0y/python-logger/publish.yaml/main?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/publish.yaml:18","Warn: pipCommand not pinned by hash: .github/workflows/publish.yaml:19","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   1 out of   1 third-party GitHubAction dependencies pinned","Info:   0 out of   2 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-24T07:37:01.677Z","repository_id":62563681,"created_at":"2025-08-24T07:37:01.677Z","updated_at":"2025-08-24T07:37:01.677Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29580640,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T08:38:15.585Z","status":"ssl_error","status_checked_at":"2026-02-18T08:38:14.917Z","response_time":162,"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":[],"created_at":"2024-10-14T03:45:43.407Z","updated_at":"2026-02-18T13:02:24.818Z","avatar_url":"https://github.com/thep0y.png","language":"Python","readme":"\u003ch1 align=\"center\"\u003ePython Colorful Logger\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://pepy.tech/project/colorful-logger\"\u003e\u003cimg alt=\"Downloads\" src=\"https://static.pepy.tech/badge/colorful-logger\"\u003e\u003c/a\u003e    \n    \u003ca href=\"https://pepy.tech/project/colorful-logger\"\u003e\u003cimg alt=\"Downloads\" src=\"https://static.pepy.tech/badge/colorful-logger/month\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://pepy.tech/project/colorful-logger\"\u003e\u003cimg alt=\"Downloads\" src=\"https://static.pepy.tech/badge/colorful-logger/week\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nA colorful logger for python3.\n\n## How to use\n\n### Install\n\n```shell\npip install colorful-logger\n```\n\n### Usage\n\n#### 1 Default Logger\n\nYou can directly use the default logger. Colored logs will be printed on the terminal. The default logger level is **warning**.\n\n```python\nfrom colorful_logger import logger\n\nwith logger:\n    logger.debug(\"default logger\")\n    logger.info(\"default logger\")\n    logger.warning(\"default logger\")\n    logger.error(\"default logger\")\n```\n\n`logger` needs to be executed inside a `with` statement, because this package uses `QueueListener` for log output. You need to call the `start` method before using `logger` to output logs, and call `stop` after you are done. I encapsulated these two methods inside `the` with statement. In most cases, there is no need to call `start` and `stop` separately.\n\n![image-20230221100744751](https://s2.loli.net/2023/02/21/yXh5d9n4vO1mW3x.png)\n\n#### 2 Custom Logger\n\nYou can also change the log level, save logs to a file, change the logger name, etc. Logs may not be printed to the terminal.\n\n```python\nfrom colorful_logger import get_logger, DEBUG\n\n\ndef demo_logger(to_file=False):\n    file = \"test_%d.log\"\n\n    l1 = get_logger(\n        \"demo\",\n        DEBUG,\n        add_file_path=False,\n        disable_line_number_filter=False,\n        file_path=file % 1 if to_file else None,\n    )\n    with l1:\n        l1.debug(\"without file path\")\n        l1.info(\"without file path\")\n        l1.warning(\"without file path\")\n        l1.error(\"without file path\")\n\n    l2 = get_logger(\n        \"demo\",\n        DEBUG,\n        add_file_path=True,\n        disable_line_number_filter=False,\n        file_path=file % 2 if to_file else None,\n    )\n    with l2:\n        l2.debug(\"with file path\")\n        l2.info(\"with file path\")\n        l2.warning(\"with file path\")\n        l2.error(\"with file path\")\n\n    l3 = get_logger(\n        None,\n        DEBUG,\n        add_file_path=True,\n        disable_line_number_filter=True,\n        file_path=file % 3 if to_file else None,\n    )\n    with l3:\n        l3.debug(\"without name, and with path\")\n        l3.info(\"without name, and with path\")\n        l3.warning(\"without name, and with path\")\n        l3.error(\"without name, and with path\")\n\n    l4 = get_logger(\n        None,\n        DEBUG,\n        add_file_path=False,\n        disable_line_number_filter=True,\n        file_path=file % 4 if to_file else None,\n    )\n    with l4:\n        l4.debug(\"without name and path\")\n        l4.info(\"without name and path\")\n        l4.warning(\"without name and path\")\n        l4.error(\"without name and path\")\n        \n    l5 = get_logger(None, DEBUG, asynchronous=False)\n    l5.debug(\"Synchronization log\")\n    l5.info(\"Synchronization log\")\n    l5.warning(\"Synchronization log\")\n    l5.error(\"Synchronization log\")\n```\n\nThere may be unexpected behavior when logging outside of the `with` statement.\n\n![截屏2023-08-06 11.40.48](https://s1.ax1x.com/2023/08/06/pPAUNFO.png)\n\nContents of the log file `./test.log` (example, inconsistent with the image above):\n\n```\n\u001b[90m10:09:33.146\u001b[0m \u001b[35mDEB\u001b[0m \u001b[36mdemo\u001b[0m\u001b[1m:26\u001b[0m \u001b[96m-\u001b[0m without file path\n\u001b[90m10:09:33.146\u001b[0m \u001b[32mINF\u001b[0m \u001b[36mdemo\u001b[0m \u001b[96m-\u001b[0m without file path\n\u001b[90m10:09:33.146\u001b[0m \u001b[33mWAR\u001b[0m \u001b[36mdemo\u001b[0m \u001b[96m-\u001b[0m without file path\n\u001b[90m10:09:33.146\u001b[0m \u001b[91mERR\u001b[0m \u001b[36mdemo\u001b[0m\u001b[1m:29\u001b[0m \u001b[96m-\u001b[0m without file path\n```\n\nThe log file does not contain color logs by default.\n\nTo save color logs to a file, set `file_colorful` to `True`. In this example, color logs are saved.\n\nThe only purpose of the color log file is to view logs in real-time in the terminal:\n\n- Unix\n\n```shell\ntail -f test.log\n# or\ncat test.log\n```\n\n- Windows\n\n```powershell\nGet-Content -Path -Wait test.log\n```\n\n##### Synchronous\n\nIf you don't want to log asynchronously, you can create a synchronous logger by passing `asynchronous=False`. In the example above, `l5` is a synchronous logger. When using a synchronous logger, you don't need to wrap the logs in a `with` statement.\n\n#### 3 Child Logger\n\nAfter defining a `logger`, I want to use all the parameters of this `logger` except for `name` to output logs. You need to use the `child_logger` method to generate a child logger. The child logger needs to be executed inside the `with` statement of the parent logger:\n\n```python\nfrom colorful_logger import get_logger, DEBUG\n\n# parent logger\nlogger = get_logger(name=\"sample_logger\", level=DEBUG, file_path=\"./test.log\")\n\nwith logger:\n    logger.error(\"parent error\")\n    l1 = logger.child(\"l1\")\n    l1.error(\"l1 error\")\n    l1.fatal(\"l1 fatal\")\n```\n\nThe child logger is the same as the parent logger except for the name. It will not log third-party libraries.\n\nExecuting the child logger inside the `with` statement of the parent logger does not mean it has to be called directly inside the `with`. It can be executed inside a function in the `with` statement:\n\n```python\n# log.py\nfrom colorful_logger import get_logger, DEBUG\n\nlogger = get_logger(name=\"sample_logger\", level=DEBUG, file_path=\"./test.log\")\n```\n\n```python\n# main.py\nfrom log import logger\nfrom other_file import test\n\nwith logger:\n    test()\n```\n\n```python\n# other_file.py\n\ntest_logger = logger.child(\"test_logger\")\n\ndef test():\n    test_logger.error(\"test error\")\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthep0y%2Fpython-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthep0y%2Fpython-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthep0y%2Fpython-logger/lists"}