{"id":23479385,"url":"https://github.com/suraj-arya/chandler","last_synced_at":"2025-04-13T17:59:01.293Z","repository":{"id":60907512,"uuid":"539447263","full_name":"suraj-arya/chandler","owner":"suraj-arya","description":"Combined python log handler to rotate log files based on both size and time.","archived":false,"fork":false,"pushed_at":"2022-10-06T11:57:53.000Z","size":409,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-16T18:17:26.439Z","etag":null,"topics":["logging","loghandler","logrotation","python","python3"],"latest_commit_sha":null,"homepage":"","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/suraj-arya.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":"2022-09-21T11:14:52.000Z","updated_at":"2025-03-15T10:13:38.000Z","dependencies_parsed_at":"2022-10-06T13:41:01.318Z","dependency_job_id":null,"html_url":"https://github.com/suraj-arya/chandler","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suraj-arya%2Fchandler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suraj-arya%2Fchandler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suraj-arya%2Fchandler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suraj-arya%2Fchandler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/suraj-arya","download_url":"https://codeload.github.com/suraj-arya/chandler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248758435,"owners_count":21156957,"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":["logging","loghandler","logrotation","python","python3"],"created_at":"2024-12-24T19:29:06.152Z","updated_at":"2025-04-13T17:59:01.264Z","avatar_url":"https://github.com/suraj-arya.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python Size and Time Based Logging File Rotating Handler\n\nPython logging's file based [handlers](https://docs.python.org/3/library/logging.handlers.html) have two different kinds of rotation. \n* [Size based rotation](https://docs.python.org/3/library/logging.handlers.html#logging.handlers.RotatingFileHandler)\n* [Time based rotation](https://docs.python.org/3/library/logging.handlers.html#logging.handlers.TimedRotatingFileHandler)\n\nHowever, these rotations work in isolation. Only one handler can be attached to a log file.\nOne can only add either Size based rotation or Time based rotation.\n\nUsing `chandler.handler.SizedAndTimedRotatingHandler` you can rotate the files based on both time and size. Files will be rotated whenever either of the conditions are met.\n\n### How to Use\n import the handler\n ```python\nfrom chandler.handler import SizedAndTimedRotatingHandler\n```\n\nThen you can initialise your loggers and append this handler.\n```python\nlogger = logging.getLogger('test-logger')\nlog_file_path = '/var/log/test/logging.log'\nrotating_handler = SizedAndTimedRotatingHandler(log_file_path, when='h', interval=1, max_bytes=50000, backup_count=3)\nlogger.addHandler(rotating_handler)\n```\nIn the above example the handler is configured to rotate every one hour or whenever the file size reaches 50k bytes.\nThis handler is built on top of [TimedRotatingFileHandler](https://docs.python.org/3/library/logging.handlers.html#logging.handlers.TimedRotatingFileHandler), so most of the arguments are similar to that of TimedRotatingFileHandler. \n\n### installation \nYou can install with pip\n```bash\n$ pip install chandler-handler\n```\n### Contribution\n\n\n#### Authors\n* [Suraj Arya](https://github.com/suraj-arya)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuraj-arya%2Fchandler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsuraj-arya%2Fchandler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuraj-arya%2Fchandler/lists"}