tinylogging


Nametinylogging JSON
Version 5.0.0 PyPI version JSON
download
home_pagehttps://github.com/HamletSargsyan/tinylogging
Summarypython logging library
upload_time2025-01-25 11:05:26
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)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/tinylogging)
![Checks](https://github.com/HamletSargsyan/tinylogging/actions/workflows/check.yml/badge.svg)
![Documentation](https://github.com/HamletSargsyan/tinylogging/actions/workflows/documentation.yml/badge.svg)

## Installation

```bash
pip install tinylogging
```

## Usage

### New logger

```python
from tinylogging import Logger, Level

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

### Logging messages

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

### Logging to a file

```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.")
```

### Custom formatting

```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.")
```

### Disabling logging

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

### Async support

```python
import asyncio
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__":
    asyncio.run(main)
```

## License

This project is licensed under the [MIT License](https://github.com/HamletSargsyan/tinylogging/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/ba/2e/a44de3aa679c53cc4418313bdc170b31d9092c81458082aecdb66e561ad4/tinylogging-5.0.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![PyPI - Python Version](https://img.shields.io/pypi/pyversions/tinylogging)\n![Checks](https://github.com/HamletSargsyan/tinylogging/actions/workflows/check.yml/badge.svg)\n![Documentation](https://github.com/HamletSargsyan/tinylogging/actions/workflows/documentation.yml/badge.svg)\n\n## Installation\n\n```bash\npip install tinylogging\n```\n\n## Usage\n\n### New logger\n\n```python\nfrom tinylogging import Logger, Level\n\nlogger = Logger(name=\"my_logger\", level=Level.DEBUG)\n```\n\n### Logging messages\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### Logging to a file\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### Custom formatting\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### Disabling logging\n\n```python\nlogger.disable()\nlogger.info(\"This message will not be logged.\")\nlogger.enable()\n```\n\n### Async support\n\n```python\nimport asyncio\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    asyncio.run(main)\n```\n\n## License\n\nThis project is licensed under the [MIT License](https://github.com/HamletSargsyan/tinylogging/blob/main/LICENSE).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "python logging library",
    "version": "5.0.0",
    "project_urls": {
        "Documentation": "https://hamletsargsyan.github.io/tinylogging",
        "Homepage": "https://github.com/HamletSargsyan/tinylogging",
        "Repository": "https://github.com/HamletSargsyan/tinylogging"
    },
    "split_keywords": [
        "logging"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a5f08382c9c427abbf19a43acd45c252825593de9141d4128d37b82350f2c5dc",
                "md5": "3cf045cd34cec6a0ccb518d738a89d75",
                "sha256": "fa6af584982a290e272e9135a001a07f2891f3f9b7fa35ce16d2604efb5482ec"
            },
            "downloads": -1,
            "filename": "tinylogging-5.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3cf045cd34cec6a0ccb518d738a89d75",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 11316,
            "upload_time": "2025-01-25T11:05:24",
            "upload_time_iso_8601": "2025-01-25T11:05:24.214717Z",
            "url": "https://files.pythonhosted.org/packages/a5/f0/8382c9c427abbf19a43acd45c252825593de9141d4128d37b82350f2c5dc/tinylogging-5.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ba2ea44de3aa679c53cc4418313bdc170b31d9092c81458082aecdb66e561ad4",
                "md5": "84a4e6e5c960ffcb6e6aa24034cb2661",
                "sha256": "6de78cd492db199c6923437ec22ad6bb0ec3fa0abf0352e25d4aca8fc7e82005"
            },
            "downloads": -1,
            "filename": "tinylogging-5.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "84a4e6e5c960ffcb6e6aa24034cb2661",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 7598,
            "upload_time": "2025-01-25T11:05:26",
            "upload_time_iso_8601": "2025-01-25T11:05:26.334462Z",
            "url": "https://files.pythonhosted.org/packages/ba/2e/a44de3aa679c53cc4418313bdc170b31d9092c81458082aecdb66e561ad4/tinylogging-5.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-25 11:05:26",
    "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: 1.40957s