# 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)
## Установка
```bash
pip install tinylogging
```
## Использование
### Create a Logger
```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.8",
"maintainer_email": null,
"keywords": "logging",
"author": "Hamlet",
"author_email": "hamlets849@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/f1/55/f20cf272a4c7a98a5252b25dee83a1950b1c6a916b39b8879bf98003285e/tinylogging-3.1.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\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### Create a Logger\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": "3.1.0",
"project_urls": {
"Homepage": "https://github.com/HamletSargsyan/tinylogging",
"Repository": "https://github.com/HamletSargsyan/tinylogging"
},
"split_keywords": [
"logging"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7075931872d804544679004f8ffffc3e40a3ce27cc572b5b153b3bb09cb32e87",
"md5": "0af538022501c988674ddb9f7fd90da1",
"sha256": "0303a6f0857b45e25096f398ba01b0bd36d20f778bdd7ea0783dafe35aeeb1c7"
},
"downloads": -1,
"filename": "tinylogging-3.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0af538022501c988674ddb9f7fd90da1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 7556,
"upload_time": "2024-10-31T14:57:21",
"upload_time_iso_8601": "2024-10-31T14:57:21.483324Z",
"url": "https://files.pythonhosted.org/packages/70/75/931872d804544679004f8ffffc3e40a3ce27cc572b5b153b3bb09cb32e87/tinylogging-3.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f155f20cf272a4c7a98a5252b25dee83a1950b1c6a916b39b8879bf98003285e",
"md5": "ab705911c88352c8d45177991e774d34",
"sha256": "aefb20f7c95c132b5d2ca374d3145bbc09c0dbfca709d66a7365003372b037c9"
},
"downloads": -1,
"filename": "tinylogging-3.1.0.tar.gz",
"has_sig": false,
"md5_digest": "ab705911c88352c8d45177991e774d34",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 4925,
"upload_time": "2024-10-31T14:57:22",
"upload_time_iso_8601": "2024-10-31T14:57:22.622690Z",
"url": "https://files.pythonhosted.org/packages/f1/55/f20cf272a4c7a98a5252b25dee83a1950b1c6a916b39b8879bf98003285e/tinylogging-3.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-31 14:57:22",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "HamletSargsyan",
"github_project": "tinylogging",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "tinylogging"
}