{"id":43623595,"url":"https://github.com/bybatkhuu/module-python-logging","last_synced_at":"2026-06-04T10:00:31.440Z","repository":{"id":192731167,"uuid":"687286323","full_name":"bybatkhuu/module-python-logging","owner":"bybatkhuu","description":"'beans-logging' is a python package for simple logger and easily managing logs.","archived":false,"fork":false,"pushed_at":"2026-05-05T13:52:22.000Z","size":2923,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-05-05T15:40:33.946Z","etag":null,"topics":["custom-logging","log-files","logger","logging","loguru","module","package","pre-defined-configs","python"],"latest_commit_sha":null,"homepage":"http://pylogging-docs.bybatkhuu.dev/","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/bybatkhuu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"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}},"created_at":"2023-09-05T03:36:40.000Z","updated_at":"2026-05-05T13:02:13.000Z","dependencies_parsed_at":"2026-03-06T07:00:17.618Z","dependency_job_id":null,"html_url":"https://github.com/bybatkhuu/module-python-logging","commit_stats":null,"previous_names":["bybatkhuu/mod.python-logging","bybatkhuu/module-python-logging"],"tags_count":40,"template":false,"template_full_name":null,"purl":"pkg:github/bybatkhuu/module-python-logging","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bybatkhuu%2Fmodule-python-logging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bybatkhuu%2Fmodule-python-logging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bybatkhuu%2Fmodule-python-logging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bybatkhuu%2Fmodule-python-logging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bybatkhuu","download_url":"https://codeload.github.com/bybatkhuu/module-python-logging/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bybatkhuu%2Fmodule-python-logging/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33899697,"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-06-04T02:00:06.755Z","response_time":64,"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":["custom-logging","log-files","logger","logging","loguru","module","package","pre-defined-configs","python"],"created_at":"2026-02-04T14:12:01.666Z","updated_at":"2026-06-04T10:00:31.389Z","avatar_url":"https://github.com/bybatkhuu.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python Logging (beans-logging)\n\n[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/bybatkhuu/module-python-logging/2.build-publish.yml?logo=GitHub)](https://github.com/bybatkhuu/module-python-logging/actions/workflows/2.build-publish.yml)\n[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/bybatkhuu/module-python-logging?logo=GitHub\u0026color=blue)](https://github.com/bybatkhuu/module-python-logging/releases)\n[![PyPI](https://img.shields.io/pypi/v/beans-logging?logo=PyPi)](https://pypi.org/project/beans-logging)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/beans-logging?logo=Python)](https://docs.conda.io/en/latest/miniconda.html)\n\n`beans-logging` is a python package for simple logger and easily managing logs.\n\nIt is a `Loguru` based custom logging package for python projects.\n\n## ✨ Features\n\n- Main **logger** based on **Loguru** logging - \u003chttps://pypi.org/project/loguru\u003e\n- Logging to **log files** (all, error, json)\n- **Pre-defined** logging configs and handlers\n- **Colorful** logging\n- Auto **intercepting** and **muting** modules\n- Load config from **YAML** or **JSON** file\n- Custom options as a **config**\n- Custom logging **formats**\n- **Multiprocess** compatibility (Linux, macOS - 'fork')\n- Add custom **handlers**\n- **Base** logging module\n\n---\n\n## 🛠 Installation\n\n### 1. 🚧 Prerequisites\n\n- Install **Python (\u003e= v3.10)** and **pip (\u003e= 23)**:\n    - **[RECOMMENDED] [Miniconda (v3)](https://www.anaconda.com/docs/getting-started/miniconda/install)**\n    - *[arm64/aarch64] [Miniforge (v3)](https://github.com/conda-forge/miniforge)*\n    - *[Python virtual environment] [venv](https://docs.python.org/3/library/venv.html)*\n\n[OPTIONAL] For **DEVELOPMENT** environment:\n\n- Install [**git**](https://git-scm.com/downloads)\n- Setup an [**SSH key**](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh)\n\n### 2. 📦 Install the package\n\n[NOTE] Choose one of the following methods to install the package **[A ~ F]**:\n\n**OPTION A.** [**RECOMMENDED**] Install from **PyPi**:\n\n```sh\npip install -U beans-logging\n```\n\n**OPTION B.** Install latest version directly from **GitHub** repository:\n\n```sh\npip install git+https://github.com/bybatkhuu/module-python-logging.git\n```\n\n**OPTION C.** Install from the downloaded **source code**:\n\n```sh\ngit clone https://github.com/bybatkhuu/module-python-logging.git \u0026\u0026 \\\n    cd ./module-python-logging\n\n# Install directly from the source code:\npip install .\n\n# Or install with editable mode:\npip install -e .\n```\n\n**OPTION D.** Install for **DEVELOPMENT** environment:\n\n```sh\npip install -e .[dev]\n\n# Install pre-commit hooks:\npre-commit install\n```\n\n**OPTION E.** Install from **pre-built release** files:\n\n1. Download **`.whl`** or **`.tar.gz`** file from [**releases**](https://github.com/bybatkhuu/module-python-logging/releases)\n2. Install with pip:\n\n```sh\n# Install from .whl file:\npip install ./beans_logging-[VERSION]-py3-none-any.whl\n\n# Or install from .tar.gz file:\npip install ./beans_logging-[VERSION].tar.gz\n```\n\n**OPTION F.** Copy the **module** into the project directory (for **testing**):\n\n```sh\n# Install python dependencies:\npip install -r ./requirements.txt\n\n# Copy the module source code into the project:\ncp -r ./src/beans_logging [PROJECT_DIR]\n# For example:\ncp -r ./src/beans_logging /some/path/project/\n```\n\n## 🚸 Usage/Examples\n\nTo use `beans_logging`, import the `logger` instance from the `beans_logging.auto` package:\n\n```python\nfrom beans_logging.auto import logger\n```\n\nYou can call logging methods directly from the `logger` instance:\n\n```python\nlogger.info(\"Logging info.\")\n```\n\n### **Simple**\n\n[**`configs/logger.yml`**](./examples/simple/configs/logger.yml):\n\n```yaml\nlogger:\n  app_name: my-app\n  level:\n    base: TRACE\n  handlers:\n    file_handler:\n      enabled: true\n    err_file_handler:\n      enabled: true\n    json_handler:\n      enabled: true\n    err_json_handler:\n      enabled: true\n```\n\n[**`main.py`**](./examples/simple/main.py):\n\n```python\n#!/usr/bin/env python\n\nfrom beans_logging.auto import logger\n\n\nlogger.trace(\"Tracing...\")\nlogger.debug(\"Debugging...\")\nlogger.info(\"Logging info.\")\nlogger.success(\"Success.\")\nlogger.warning(\"Warning something.\")\nlogger.error(\"Error occured.\")\nlogger.critical(\"CRITICAL ERROR.\")\n\n\ndef divide(a, b):\n    _result = a / b\n    return _result\n\n\ndef nested(c):\n    try:\n        divide(5, c)\n    except ZeroDivisionError as err:\n        logger.error(err)\n        raise\n\n\ntry:\n    nested(0)\nexcept Exception:\n    logger.exception(\"Show me, what value is wrong:\")\n```\n\nRun the [**`examples/simple`**](./examples/simple):\n\n```sh\ncd ./examples/simple\n\npython ./main.py\n```\n\n**Output**:\n\n```txt\n[2025-11-01 00:00:00.735 +09:00 | TRACE | beans_logging._intercept:96]: Intercepted modules: ['potato_util._base', 'potato_util.io', 'concurrent', 'concurrent.futures', 'asyncio', 'potato_util.io._sync', 'potato_util']; Muted modules: [];\n[2025-11-01 00:00:00.736 +09:00 | TRACE | __main__:6]: Tracing...\n[2025-11-01 00:00:00.736 +09:00 | DEBUG | __main__:7]: Debugging...\n[2025-11-01 00:00:00.736 +09:00 | INFO  | __main__:8]: Logging info.\n[2025-11-01 00:00:00.736 +09:00 | OK    | __main__:9]: Success.\n[2025-11-01 00:00:00.736 +09:00 | WARN  | __main__:10]: Warning something.\n[2025-11-01 00:00:00.736 +09:00 | ERROR | __main__:11]: Error occured.\n[2025-11-01 00:00:00.736 +09:00 | CRIT  | __main__:12]: CRITICAL ERROR.\n[2025-11-01 00:00:00.736 +09:00 | ERROR | __main__:24]: division by zero\n[2025-11-01 00:00:00.737 +09:00 | ERROR | __main__:31]: Show me, what value is wrong:\nTraceback (most recent call last):\n\n\u003e File \"/home/user/workspaces/projects/my/module-python-logging/examples/simple/./main.py\", line 29, in \u003cmodule\u003e\n    nested(0)\n    └ \u003cfunction nested at 0x102f37910\u003e\n\n  File \"/home/user/workspaces/projects/my/module-python-logging/examples/simple/./main.py\", line 22, in nested\n    divide(5, c)\n    │         └ 0\n    └ \u003cfunction divide at 0x102f377f0\u003e\n\n  File \"/home/user/workspaces/projects/my/module-python-logging/examples/simple/./main.py\", line 16, in divide\n    _result = a / b\n              │   └ 0\n              └ 5\n\nZeroDivisionError: division by zero\n```\n\n👍\n\n---\n\n## ⚙️ Configuration\n\n[**`templates/configs/logger.yml`**](./templates/configs/logger.yml):\n\n```yaml\nlogger:\n  # app_name: app\n  level:\n    base: INFO\n    err: WARNING\n  format_str: \"[{time:YYYY-MM-DD HH:mm:ss.SSS Z} | {extra[level_short]:\u003c5} | {name}:{line}]: {message}\"\n  file:\n    logs_dir: \"./logs\"\n    rotate_size: 10000000\n    rotate_time: \"00:00:00\"\n    retention: 90\n    encoding: utf8\n  use_custom_serialize: false\n  intercept:\n    enabled: true\n    only_base: false\n    ignore_modules: []\n    include_modules: []\n    mute_modules: []\n  handlers:\n    std_handler:\n      enabled: true\n      h_type: STD\n      format: \"[\u003cc\u003e{time:YYYY-MM-DD HH:mm:ss.SSS Z}\u003c/c\u003e | \u003clevel\u003e{extra[level_short]:\u003c5}\u003c/level\u003e | \u003cw\u003e{name}:{line}\u003c/w\u003e]: \u003clevel\u003e{message}\u003c/level\u003e\"\n      colorize: true\n    file_handler:\n      enabled: false\n      h_type: FILE\n      sink: \"{app_name}.all.log\"\n    err_file_handler:\n      enabled: false\n      h_type: FILE\n      sink: \"{app_name}.err.log\"\n      error: true\n    json_handler:\n      enabled: false\n      h_type: FILE\n      sink: \"json/{app_name}.all.json.log\"\n      serialize: true\n    err_json_handler:\n      enabled: false\n      h_type: FILE\n      sink: \"json/{app_name}.err.json.log\"\n      serialize: true\n      error: true\n  extra:\n```\n\n### 🌎 Environment Variables\n\n[**`.env.example`**](./.env.example):\n\n```sh\n# ENV=LOCAL\n# DEBUG=false\n# TZ=UTC\n```\n\n---\n\n## 🧪 Running Tests\n\nTo run tests, run the following command:\n\n```sh\n# Install python test dependencies:\npip install .[test]\n\n# Run tests:\npython -m pytest -sv -o log_cli=true\n# Or use the test script:\n./scripts/test.sh -l -v -c\n```\n\n## 🏗️ Build Package\n\nTo build the python package, run the following command:\n\n```sh\n# Install python build dependencies:\npip install -r ./requirements/requirements.build.txt\n\n# Build python package:\npython -m build\n# Or use the build script:\n./scripts/build.sh\n```\n\n## 📝 Generate Docs\n\nTo build the documentation, run the following command:\n\n```sh\n# Install python documentation dependencies:\npip install -r ./requirements/requirements.docs.txt\n\n# Serve documentation locally (for development):\nmkdocs serve -a 0.0.0.0:8000 --livereload\n# Or use the docs script:\n./scripts/docs.sh\n\n# Or build documentation:\nmkdocs build\n# Or use the docs script:\n./scripts/docs.sh -b\n```\n\n## 📚 Documentation\n\n- [Docs](./docs)\n\n---\n\n## 📑 References\n\n- \u003chttps://github.com/Delgan/loguru\u003e\n- \u003chttps://loguru.readthedocs.io/en/stable/api/logger.html\u003e\n- \u003chttps://loguru.readthedocs.io/en/stable/resources/recipes.html\u003e\n- \u003chttps://docs.python.org/3/library/logging.html\u003e\n- \u003chttps://github.com/bybatkhuu/module-fastapi-logging\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbybatkhuu%2Fmodule-python-logging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbybatkhuu%2Fmodule-python-logging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbybatkhuu%2Fmodule-python-logging/lists"}