tasks-logger


Nametasks-logger JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/glizzykingdreko/tasks-logger
SummarySimplify complex logging in Python with customizable, color-coded, and thread-safe outputs.
upload_time2024-05-03 18:43:14
maintainerNone
docs_urlNone
authorGlizzyKingDreko
requires_python>=3.6
licenseNone
keywords
VCS
bugtrack_url
requirements colorama
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Tasks Logger
![Logo](https://i.imgur.com/sI4C8kC.jpeg)

## Overview
`tasks-logger` is a versatile Python logging library designed to facilitate detailed and color-coded logging for applications that manage multiple tasks, such as those operating across various threads or processes. It extends the basic functionality of Python’s built-in logging module to include dynamic log levels, thread-safe output, conditional file logging, and vivid color outputs for better clarity and monitoring.

Check also [tasks-loader](https://github.com/glizzykingdreko/tasks-loader/)

## Table Of Contents
- [Tasks Logger](#tasks-logger)
  - [Overview](#overview)
  - [Table Of Contents](#table-of-contents)
  - [Features](#features)
  - [Installation](#installation)
  - [How It Works](#how-it-works)
  - [Usage](#usage)
    - [Basic Setup](#basic-setup)
    - [Adding New Log Levels](#adding-new-log-levels)
    - [Thread-Safe Logging](#thread-safe-logging)
    - [Conditional File Logging](#conditional-file-logging)
  - [Example Application: Sneakers/Tickets Bot](#example-application-sneakerstickets-bot)
  - [Stay in touch with me](#stay-in-touch-with-me)


## Features
- **Dynamic Log Levels**: Easily define new log levels on the fly.
- **Color-coded Output**: Enhance log visibility with configurable color outputs for each log level.
- **Conditional File Logging**: Decide which log level messages are important enough to save to files.
- **Thread Safety**: Ensure logs are thread-safe using locks to prevent text scrambling when used in multi-threaded applications.

## Installation
Install `tasks-logger` via pip:

```bash
pip install tasks-logger
```

## How It Works
`tasks-logger` utilizes the Colorama library to add color to log messages depending on their severity. You can set up different log levels and specify whether these should be output to the console, saved to a file, or both. The logger also supports dynamic addition of new log levels with specific properties.

## Usage

### Basic Setup
Here's how to set up and use the `tasks-logger`:

```python
from tasks_logger import Logger

logger = Logger(level='INFO', file_level='ERROR', filename='app.log')
logger.info("This is an informational message.")
logger.error("This error message will also be saved to a file.")
```

### Adding New Log Levels
You can add new log levels dynamically:

```python
logger.add_level('VERBOSE', 15, Fore.LIGHTBLUE_EX)
logger.verbose("This is a verbose message with custom log level.")
```

### Thread-Safe Logging
`tasks-logger` is designed to be safe for use in multi-threaded environments:

```python
import threading

def task():
    logger.info("Log from a thread.")

thread = threading.Thread(target=task)
thread.start()
thread.join()
```

### Conditional File Logging
Control which log levels are logged to files:

```python
# Only ERROR and above levels will be saved to the file.
logger = Logger(level='DEBUG', file_level='ERROR', filename='important.log')
logger.debug("This message will not be logged in the file.")
logger.error("This error will be logged in the file.")
```

## Example Application: Sneakers/Tickets Bot

Here is an example showing how `tasks-logger` might be used in a sneakers/tickets purchasing bot, which operates with multiple tasks:

```python
class MyTask:
    def __init__(self, task_id: str, mail: str, ...):
        self.logger = Logger(
            level='INFO', 
            task_id=task_id,
            mail=mail,
            formatting="[{timestamp}] [{level}] ({task_id}) {mail} - {message}"
        )

```


## Stay in touch with me

For any inquiries or further information, please reach out:

- [GitHub](https://github.com/glizzykingdreko)
- [Twitter](https://mobile.twitter.com/glizzykingdreko)
- [Medium](https://medium.com/@glizzykingdreko)
- [Email](mailto:glizzykingdreko@protonmail.com) 
- [Website](https://glizzykingdreko.github.io)
- [Buy me a coffee ❤️](https://www.buymeacoffee.com/glizzykingdreko)
- Antibot bypass solutions needed? [TakionAPI](https://takionapi.tech/discord)

Feel free to contact for collaborations, questions, or feedback any of my projects.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/glizzykingdreko/tasks-logger",
    "name": "tasks-logger",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "GlizzyKingDreko",
    "author_email": "glizzykingdreko@protonmail.com",
    "download_url": "https://files.pythonhosted.org/packages/4b/67/3388b1aaf18cd3ded5a9f8a331c5c89d64ef876f41d19c39b4a8d3f9dfe3/tasks-logger-0.1.0.tar.gz",
    "platform": null,
    "description": "# Tasks Logger\n![Logo](https://i.imgur.com/sI4C8kC.jpeg)\n\n## Overview\n`tasks-logger` is a versatile Python logging library designed to facilitate detailed and color-coded logging for applications that manage multiple tasks, such as those operating across various threads or processes. It extends the basic functionality of Python\u2019s built-in logging module to include dynamic log levels, thread-safe output, conditional file logging, and vivid color outputs for better clarity and monitoring.\n\nCheck also [tasks-loader](https://github.com/glizzykingdreko/tasks-loader/)\n\n## Table Of Contents\n- [Tasks Logger](#tasks-logger)\n  - [Overview](#overview)\n  - [Table Of Contents](#table-of-contents)\n  - [Features](#features)\n  - [Installation](#installation)\n  - [How It Works](#how-it-works)\n  - [Usage](#usage)\n    - [Basic Setup](#basic-setup)\n    - [Adding New Log Levels](#adding-new-log-levels)\n    - [Thread-Safe Logging](#thread-safe-logging)\n    - [Conditional File Logging](#conditional-file-logging)\n  - [Example Application: Sneakers/Tickets Bot](#example-application-sneakerstickets-bot)\n  - [Stay in touch with me](#stay-in-touch-with-me)\n\n\n## Features\n- **Dynamic Log Levels**: Easily define new log levels on the fly.\n- **Color-coded Output**: Enhance log visibility with configurable color outputs for each log level.\n- **Conditional File Logging**: Decide which log level messages are important enough to save to files.\n- **Thread Safety**: Ensure logs are thread-safe using locks to prevent text scrambling when used in multi-threaded applications.\n\n## Installation\nInstall `tasks-logger` via pip:\n\n```bash\npip install tasks-logger\n```\n\n## How It Works\n`tasks-logger` utilizes the Colorama library to add color to log messages depending on their severity. You can set up different log levels and specify whether these should be output to the console, saved to a file, or both. The logger also supports dynamic addition of new log levels with specific properties.\n\n## Usage\n\n### Basic Setup\nHere's how to set up and use the `tasks-logger`:\n\n```python\nfrom tasks_logger import Logger\n\nlogger = Logger(level='INFO', file_level='ERROR', filename='app.log')\nlogger.info(\"This is an informational message.\")\nlogger.error(\"This error message will also be saved to a file.\")\n```\n\n### Adding New Log Levels\nYou can add new log levels dynamically:\n\n```python\nlogger.add_level('VERBOSE', 15, Fore.LIGHTBLUE_EX)\nlogger.verbose(\"This is a verbose message with custom log level.\")\n```\n\n### Thread-Safe Logging\n`tasks-logger` is designed to be safe for use in multi-threaded environments:\n\n```python\nimport threading\n\ndef task():\n    logger.info(\"Log from a thread.\")\n\nthread = threading.Thread(target=task)\nthread.start()\nthread.join()\n```\n\n### Conditional File Logging\nControl which log levels are logged to files:\n\n```python\n# Only ERROR and above levels will be saved to the file.\nlogger = Logger(level='DEBUG', file_level='ERROR', filename='important.log')\nlogger.debug(\"This message will not be logged in the file.\")\nlogger.error(\"This error will be logged in the file.\")\n```\n\n## Example Application: Sneakers/Tickets Bot\n\nHere is an example showing how `tasks-logger` might be used in a sneakers/tickets purchasing bot, which operates with multiple tasks:\n\n```python\nclass MyTask:\n    def __init__(self, task_id: str, mail: str, ...):\n        self.logger = Logger(\n            level='INFO', \n            task_id=task_id,\n            mail=mail,\n            formatting=\"[{timestamp}] [{level}] ({task_id}) {mail} - {message}\"\n        )\n\n```\n\n\n## Stay in touch with me\n\nFor any inquiries or further information, please reach out:\n\n- [GitHub](https://github.com/glizzykingdreko)\n- [Twitter](https://mobile.twitter.com/glizzykingdreko)\n- [Medium](https://medium.com/@glizzykingdreko)\n- [Email](mailto:glizzykingdreko@protonmail.com) \n- [Website](https://glizzykingdreko.github.io)\n- [Buy me a coffee \u2764\ufe0f](https://www.buymeacoffee.com/glizzykingdreko)\n- Antibot bypass solutions needed? [TakionAPI](https://takionapi.tech/discord)\n\nFeel free to contact for collaborations, questions, or feedback any of my projects.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Simplify complex logging in Python with customizable, color-coded, and thread-safe outputs.",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/glizzykingdreko/tasks-logger"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c58bc4c0bfaa0984811c2776f2ecacd3faf36bb4f0a1fe93ea7b93d906bf9fbd",
                "md5": "4784a5871e3407a90afd3a9ce3c5708d",
                "sha256": "ea4e35d66e921b5423c06980748e5ae7f7d1392b850a5c5f98fd72669474b101"
            },
            "downloads": -1,
            "filename": "tasks_logger-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4784a5871e3407a90afd3a9ce3c5708d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 5083,
            "upload_time": "2024-05-03T18:43:12",
            "upload_time_iso_8601": "2024-05-03T18:43:12.346994Z",
            "url": "https://files.pythonhosted.org/packages/c5/8b/c4c0bfaa0984811c2776f2ecacd3faf36bb4f0a1fe93ea7b93d906bf9fbd/tasks_logger-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4b673388b1aaf18cd3ded5a9f8a331c5c89d64ef876f41d19c39b4a8d3f9dfe3",
                "md5": "fd3a1ee23d4ff2418891fdbf3f352d6d",
                "sha256": "a6dba5c891f1063171806876170b343346f491d1b14ac83baafe00e8e63e2c06"
            },
            "downloads": -1,
            "filename": "tasks-logger-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "fd3a1ee23d4ff2418891fdbf3f352d6d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 4881,
            "upload_time": "2024-05-03T18:43:14",
            "upload_time_iso_8601": "2024-05-03T18:43:14.196786Z",
            "url": "https://files.pythonhosted.org/packages/4b/67/3388b1aaf18cd3ded5a9f8a331c5c89d64ef876f41d19c39b4a8d3f9dfe3/tasks-logger-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-03 18:43:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "glizzykingdreko",
    "github_project": "tasks-logger",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "colorama",
            "specs": [
                [
                    "==",
                    "0.4.6"
                ]
            ]
        }
    ],
    "lcname": "tasks-logger"
}
        
Elapsed time: 0.22828s