tinylogging


Nametinylogging JSON
Version 4.2.0 PyPI version JSON
download
home_pagehttps://github.com/HamletSargsyan/tinylogging
SummaryNone
upload_time2025-01-17 17:58:59
maintainerNone
docs_urlNone
authorHamlet
requires_python<4.0,>=3.9
licenseMIT
keywords logging
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # tinylogging

![GitHub License](https://img.shields.io/github/license/HamletSargsyan/tinylogging)
![GitHub commit activity](https://img.shields.io/github/commit-activity/m/HamletSargsyan/tinylogging)
![PyPI - Downloads](https://img.shields.io/pypi/dm/tinylogging)
![PyPI - Version](https://img.shields.io/pypi/v/tinylogging)
![Checks](https://github.com/HamletSargsyan/tinylogging/actions/workflows/check.yml/badge.svg)

## Установка

```bash
pip install tinylogging
```

## Использование

### Создание нового логгера

```python
from tinylogging import Logger, Level

logger = Logger(name="my_logger", level=Level.DEBUG)

```

### Логирование сообщений

```python
logger.info("This is an info message.")
logger.error("This is an error message.")
logger.debug("This is a debug message.")
```

### Логирования в файл

```python
from tinylogging import FileHandler

file_handler = FileHandler(file_name="app.log", level=Level.WARNING)
logger.handlers.add(file_handler)

logger.warning("This warning will be logged to both console and file.")
```

### Пользовательское форматирование

```python
from tinylogging import Formatter

formatter = Formatter(template="{time} - {name} - {level} - {message}", colorize=False)
logger = Logger(name="custom_logger", formatter=formatter)
logger.info("This log message uses a custom format.")
```

### Отключение логирования

```python
logger.disable()
logger.info("This message will not be logged.")
logger.enable()
```

### Поддержка асинхронности

```python
import anyio
from tinylogging import AsyncLogger, AsyncFileHandler


async def main():
    logger = AsyncLogger(name="async_logger")

    file_handler = AsyncFileHandler(file_name="app.log")
    logger.handlers.add(file_handler)

    await logger.info("This is an info message.")
    await logger.error("This is an error message.")
    await logger.debug("This is a debug message.")


if __name__ == "__main__":
    anyio.run(main)
```

## Лицензия

Этот проект лицензирован под лицензией [MIT](https://github.com/HamletSargsyan/tiny-logging/blob/main/LICENSE).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/HamletSargsyan/tinylogging",
    "name": "tinylogging",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": "logging",
    "author": "Hamlet",
    "author_email": "hamlets849@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/81/f3/e8ffe3cc2b8b942dd6fa5abd68faa8002911b5cc0c3e4f37353dde6bcdcc/tinylogging-4.2.0.tar.gz",
    "platform": null,
    "description": "# tinylogging\n\n![GitHub License](https://img.shields.io/github/license/HamletSargsyan/tinylogging)\n![GitHub commit activity](https://img.shields.io/github/commit-activity/m/HamletSargsyan/tinylogging)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/tinylogging)\n![PyPI - Version](https://img.shields.io/pypi/v/tinylogging)\n![Checks](https://github.com/HamletSargsyan/tinylogging/actions/workflows/check.yml/badge.svg)\n\n## \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430\n\n```bash\npip install tinylogging\n```\n\n## \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\n\n### \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u043b\u043e\u0433\u0433\u0435\u0440\u0430\n\n```python\nfrom tinylogging import Logger, Level\n\nlogger = Logger(name=\"my_logger\", level=Level.DEBUG)\n\n```\n\n### \u041b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439\n\n```python\nlogger.info(\"This is an info message.\")\nlogger.error(\"This is an error message.\")\nlogger.debug(\"This is a debug message.\")\n```\n\n### \u041b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0444\u0430\u0439\u043b\n\n```python\nfrom tinylogging import FileHandler\n\nfile_handler = FileHandler(file_name=\"app.log\", level=Level.WARNING)\nlogger.handlers.add(file_handler)\n\nlogger.warning(\"This warning will be logged to both console and file.\")\n```\n\n### \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\n\n```python\nfrom tinylogging import Formatter\n\nformatter = Formatter(template=\"{time} - {name} - {level} - {message}\", colorize=False)\nlogger = Logger(name=\"custom_logger\", formatter=formatter)\nlogger.info(\"This log message uses a custom format.\")\n```\n\n### \u041e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f\n\n```python\nlogger.disable()\nlogger.info(\"This message will not be logged.\")\nlogger.enable()\n```\n\n### \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0441\u0442\u0438\n\n```python\nimport anyio\nfrom tinylogging import AsyncLogger, AsyncFileHandler\n\n\nasync def main():\n    logger = AsyncLogger(name=\"async_logger\")\n\n    file_handler = AsyncFileHandler(file_name=\"app.log\")\n    logger.handlers.add(file_handler)\n\n    await logger.info(\"This is an info message.\")\n    await logger.error(\"This is an error message.\")\n    await logger.debug(\"This is a debug message.\")\n\n\nif __name__ == \"__main__\":\n    anyio.run(main)\n```\n\n## \u041b\u0438\u0446\u0435\u043d\u0437\u0438\u044f\n\n\u042d\u0442\u043e\u0442 \u043f\u0440\u043e\u0435\u043a\u0442 \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u0440\u043e\u0432\u0430\u043d \u043f\u043e\u0434 \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u0435\u0439 [MIT](https://github.com/HamletSargsyan/tiny-logging/blob/main/LICENSE).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": null,
    "version": "4.2.0",
    "project_urls": {
        "Homepage": "https://github.com/HamletSargsyan/tinylogging",
        "Repository": "https://github.com/HamletSargsyan/tinylogging"
    },
    "split_keywords": [
        "logging"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9a00cc884f3c96e265a89f19303d71ecb849cca0725041c5df3fa636dab19a56",
                "md5": "d8790cb39f459376f96ed58f3723158e",
                "sha256": "098c320eaedbd4da36c7518465c810b506ffff4178e9e5b8f6a3ece7dfaf3da0"
            },
            "downloads": -1,
            "filename": "tinylogging-4.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d8790cb39f459376f96ed58f3723158e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 8983,
            "upload_time": "2025-01-17T17:58:56",
            "upload_time_iso_8601": "2025-01-17T17:58:56.314811Z",
            "url": "https://files.pythonhosted.org/packages/9a/00/cc884f3c96e265a89f19303d71ecb849cca0725041c5df3fa636dab19a56/tinylogging-4.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "81f3e8ffe3cc2b8b942dd6fa5abd68faa8002911b5cc0c3e4f37353dde6bcdcc",
                "md5": "1f4e55b3bf22c6e3fe1e56d27d5b26a4",
                "sha256": "bd1f3952e3ddc2b6e1a14f4acf92cbf5357abc839dea981a37d76c60559932e8"
            },
            "downloads": -1,
            "filename": "tinylogging-4.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "1f4e55b3bf22c6e3fe1e56d27d5b26a4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 5355,
            "upload_time": "2025-01-17T17:58:59",
            "upload_time_iso_8601": "2025-01-17T17:58:59.020223Z",
            "url": "https://files.pythonhosted.org/packages/81/f3/e8ffe3cc2b8b942dd6fa5abd68faa8002911b5cc0c3e4f37353dde6bcdcc/tinylogging-4.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-17 17:58:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "HamletSargsyan",
    "github_project": "tinylogging",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "tinylogging"
}
        
Elapsed time: 0.58134s