{"id":19862790,"url":"https://github.com/pyunits/pyunit-log","last_synced_at":"2026-05-30T23:31:44.633Z","repository":{"id":57458194,"uuid":"239278622","full_name":"pyunits/pyunit-log","owner":"pyunits","description":"简单的快速的函数日志处理模块","archived":false,"fork":false,"pushed_at":"2020-09-02T07:52:44.000Z","size":14,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-14T10:34:09.837Z","etag":null,"topics":["log","logging","python3"],"latest_commit_sha":null,"homepage":"https://pyunit-log.readthedocs.io/en/latest/pyunit_log.html#module-pyunit_log.log","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pyunits.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-09T09:35:49.000Z","updated_at":"2023-09-19T10:45:18.000Z","dependencies_parsed_at":"2022-09-09T22:51:21.995Z","dependency_job_id":null,"html_url":"https://github.com/pyunits/pyunit-log","commit_stats":null,"previous_names":["pyunit/pyunit-log"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pyunits/pyunit-log","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyunits%2Fpyunit-log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyunits%2Fpyunit-log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyunits%2Fpyunit-log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyunits%2Fpyunit-log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pyunits","download_url":"https://codeload.github.com/pyunits/pyunit-log/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyunits%2Fpyunit-log/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33714033,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-30T02:00:06.278Z","response_time":92,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["log","logging","python3"],"created_at":"2024-11-12T15:12:40.966Z","updated_at":"2026-05-30T23:31:44.607Z","avatar_url":"https://github.com/pyunits.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **pyUnit-log** [![](https://gitee.com/tyoui/logo/raw/master/logo/photolog.png)][1]\n\n## 日志处理模块集合\n[![](https://img.shields.io/badge/Python-3.7-green.svg)](https://pypi.org/project/pyunit-log/)\n\n## 安装\n    pip install pyunit-log\n\n## 亮点\n    快速简单的函数日志模块，只需要在函数头上写一个装饰器即可，一行代码解决日志问题。\n    @log(log_file='./logs')\n\n### 日志装饰器\n```python\nfrom pyunit_log import log\n\nif __name__ == '__main__':\n    #config_file是日志模板地址,不写默认加载\n    @log(log_file='./logs',config_file=None)\n    def division():\n        pass\n```\n\n### 加载默认日志配置\n```python\nfrom pyunit_log import Log\nimport logging\n\nif __name__ == '__main__':\n    Log()\n\n    logging.info('默认加载到root下')\n\n    info = logging.getLogger('info')\n    info.info('日志文件写道info.log文件下')\n\n    error = logging.getLogger('error')\n    error.error('日志文件写道error.log文件下')\n```\n\n### 修改日志配置文件\n```python\nfrom pyunit_log import Log\nimport logging\n\nif __name__ == '__main__':\n    Log(config_file = '',log_file = '')\n    # log_file 修改保存日志文件夹地址\n    # config_file 修改配置文件地址\n\n    info = logging.getLogger('info')\n    info.info('日志文件写道info.log文件下')\n\n    error = logging.getLogger('error')\n    error.error('日志文件写道error.log文件下')\n```\n\n### [修改配置文件格式](https://docs.python.org/zh-cn/3.7/library/logging.handlers.html?highlight=timedrotatingfilehandler)\n```log\n[loggers]\nkeys = root,info,error\n\n[handlers]\nkeys = console,info,error\n\n[formatters]\nkeys = simpleFormatter\n\n[formatter_simpleFormatter]\nformat = %(asctime)s - %(module)s - %(thread)d - %(levelname)s : %(message)s\ndatefmt = %Y-%m-%d %H:%M:%S\n\n[logger_root]\nlevel = INFO\nhandlers = info,console\n\n[handler_console]\nclass = StreamHandler\nlevel = INFO\nformatter = simpleFormatter\nargs = (sys.stdout,)\n\n[logger_info]\nlevel = INFO\nhandlers = info\nqualname = info\npropagate = 0\n\n[handler_info]\nclass = handlers.RotatingFileHandler\nformatter = simpleFormatter\nargs = ('logs/info.log', 'a', 1048576, 30, 'UTF-8')\n\n[logger_error]\nlevel = ERROR\nhandlers = error\nqualname = error\npropagate = 0\n\n[handler_error]\nclass = handlers.TimedRotatingFileHandler\nformatter = simpleFormatter\nargs = ('logs/error.log', 'D', 1, 30, 'UTF-8')\n```\n\n#### 日志大小说明\n    默认：info日志是1M（1048576）分割\n    error日志是每天分割\n\n***\n[1]: https://blog.jtyoui.com","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyunits%2Fpyunit-log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpyunits%2Fpyunit-log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyunits%2Fpyunit-log/lists"}