pretty-verbose


Namepretty-verbose JSON
Version 0.1.2.post3 PyPI version JSON
download
home_pageNone
SummaryPackage for colored organized verbose printing in python.
upload_time2025-04-15 07:43:50
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License Copyright (c) 2022 Cindy Catalina Moreno Sarria Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords verbose log logger colors print
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Pretty Verbose
[![PyPI version](https://img.shields.io/pypi/v/pretty-verbose.svg)](https://pypi.org/project/pretty-verbose/)
[![License](https://img.shields.io/github/license/ccmorenos/pretty_verbose
)](https://github.com/ccmorenos/pretty_verbose/blob/main/LICENSE)
[![Test Python Package](https://github.com/ccmorenos/pretty_verbose/actions/workflows/test-python.yml/badge.svg?branch=main)](https://github.com/ccmorenos/pretty_verbose/actions/workflows/test-python.yml) [![Upload Python Package](https://github.com/ccmorenos/pretty_verbose/actions/workflows/python-publish.yml/badge.svg)](https://github.com/ccmorenos/pretty_verbose/actions/workflows/python-publish.yml)

Package for beautiful verbose printing in python.

## Installation

The package is available in the [Python Package Index (PyPi)](https://pypi.org/project/pretty-verbose/).

```bash
python3 -m pip install pretty_verbose
```

## Examples

### Simple output

To use the verbose output, create a `VerboseMessages` object.

```python
from pretty_verbose import VerboseMessages

messages = VerboseMessages(
    level=3,
    name="main",
    filename="messages.log",
    log_dir="path/to/log_dir"  # Optional for saving the log in the given dir.
)
```

The level indicates which messages will be printed.

* -1: Just Debug.
* 0: Debug and Errors.
* 1: Debug, Errors and Warnings.
* 2: Debug, Errors Warnings and Success.
* 3: Debug, Errors Warnings, Success and Info.

The name works to use the VerboseMessages in several instance and
differentiate where the message is coming from. Finally the filename will store
all the messages printed in the terminal.

The following messages can be printed.

```python
import time

messages.debug("This is a debug message.")
messages.error("This is an error message.")
messages.warning("This is a warning message.")
messages.success("This is a success message.")
messages.info("This is an info message.")

for i in range(100):
    if i % 10 == 0:
        messages.for_message("This is an info message inside a for loop.")
    messages.progress("This is a progress message.", (i+1))
    time.sleep(0.1)
```

The result will be the following.

```
[28/08/2022 14:12:09] DEBUG [main]: This is an debug message.
[28/08/2022 14:12:09] ERROR [main]: This is an error message.
[28/08/2022 14:12:09] WARNING [main]: This is a warning message.
[28/08/2022 14:12:09] SUCCESS [main]: This is a success message.
[28/08/2022 14:14:06] SUCCESS [main]: This is a success message.
[28/08/2022 14:12:10] INFO [main] -- This is an info message inside a for loop.
[28/08/2022 14:12:11] INFO [main] -- This is an info message inside a for loop.
[28/08/2022 14:12:13] INFO [main] -- This is an info message inside a for loop.
[28/08/2022 14:12:14] INFO [main] -- This is an info message inside a for loop.
[28/08/2022 14:12:15] INFO [main] -- This is an info message inside a for loop.
[28/08/2022 14:12:16] INFO [main] -- This is an info message inside a for loop.
[28/08/2022 14:12:17] INFO [main] -- This is an info message inside a for loop.
[28/08/2022 14:12:18] INFO [main] -- This is an info message inside a for loop.
[28/08/2022 14:12:19] INFO [main] -- This is an info message inside a for loop.
[28/08/2022 14:12:20] INFO [main] -- This is an info message inside a for loop.
[28/08/2022 14:14:19] INFO [main] -- This is a progress message.: [100.00%]
```

### Tasks and Processes

There are more complete classes such as `Task` and `Process` that allow
measurement of execution time as well as creating subordinate verbose messages.
Both are equipped with all the printing function as they are inherited from the
`VerboseMessages` class.

With `Task` it is possible to measure how long it takes to complete a execution of a function:

```python
task1 = Task(level=5, name="task1")

ex_time = task1.exec_time(
    some_callable,  # Function from which measure the execution time.
    arg1, arg2,  # Arguments of the function.
    print_timer=True  # Print the time execution as it just return it.
)
ex_time = task1.exec_many_time(
    callable1, callable2, callable3,  # Functions from which measure the execution time.
    [[f1_arg1, f1_arg2], [], [f3_arg1]], # Arguments of the functions.
    print_timer=True  # Print the time execution as it just return it.
)
```

Additionally it is possible just to activate, deactivate, get the partial and
total time of the timer.

```python
task1.start_timer()

# ...some code ...
lap_time = task1.lap()

# ...some code ...
task1.print_lap()

# ...some code ...
task1.stop_timer()

total_t = task1.total_time()
```

With `Process` it is possible to create subtasks and subprocesses associated to
it.

```python
main_process = Process(level=5, name="main")

subprocess_1: Process = main_process.new_subprocess("subprocess_1")
subprocess_2: Process = main_process.new_subprocess("subprocess_2")
subtask_2: Task = main_process.new_task("subtask_1")

# Subprocess as they are Process object, they can also create new processes and
# tasks.
subsubprocess_1: Process = subprocess_1.new_subprocess("subsubprocess_1")
subsubtask_2: Task = subprocess_1.new_task("subsubtask_1")
```

All the `Process` objects are also equipped with the timer functions as it
inherits from the `Task` class.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pretty-verbose",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "\"C. Catalina M. Sarria\" <ccatamorenos@gmail.com>",
    "keywords": "verbose, log, logger, colors, print",
    "author": null,
    "author_email": "\"C. Catalina M. Sarria\" <ccatamorenos@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/ac/7b/b23bc6ae2f7a86ce76920e10b8d616fc45013e4bcb12941e31ab3424c120/pretty_verbose-0.1.2.post3.tar.gz",
    "platform": null,
    "description": "# Pretty Verbose\n[![PyPI version](https://img.shields.io/pypi/v/pretty-verbose.svg)](https://pypi.org/project/pretty-verbose/)\n[![License](https://img.shields.io/github/license/ccmorenos/pretty_verbose\n)](https://github.com/ccmorenos/pretty_verbose/blob/main/LICENSE)\n[![Test Python Package](https://github.com/ccmorenos/pretty_verbose/actions/workflows/test-python.yml/badge.svg?branch=main)](https://github.com/ccmorenos/pretty_verbose/actions/workflows/test-python.yml) [![Upload Python Package](https://github.com/ccmorenos/pretty_verbose/actions/workflows/python-publish.yml/badge.svg)](https://github.com/ccmorenos/pretty_verbose/actions/workflows/python-publish.yml)\n\nPackage for beautiful verbose printing in python.\n\n## Installation\n\nThe package is available in the [Python Package Index (PyPi)](https://pypi.org/project/pretty-verbose/).\n\n```bash\npython3 -m pip install pretty_verbose\n```\n\n## Examples\n\n### Simple output\n\nTo use the verbose output, create a `VerboseMessages` object.\n\n```python\nfrom pretty_verbose import VerboseMessages\n\nmessages = VerboseMessages(\n    level=3,\n    name=\"main\",\n    filename=\"messages.log\",\n    log_dir=\"path/to/log_dir\"  # Optional for saving the log in the given dir.\n)\n```\n\nThe level indicates which messages will be printed.\n\n* -1: Just Debug.\n* 0: Debug and Errors.\n* 1: Debug, Errors and Warnings.\n* 2: Debug, Errors Warnings and Success.\n* 3: Debug, Errors Warnings, Success and Info.\n\nThe name works to use the VerboseMessages in several instance and\ndifferentiate where the message is coming from. Finally the filename will store\nall the messages printed in the terminal.\n\nThe following messages can be printed.\n\n```python\nimport time\n\nmessages.debug(\"This is a debug message.\")\nmessages.error(\"This is an error message.\")\nmessages.warning(\"This is a warning message.\")\nmessages.success(\"This is a success message.\")\nmessages.info(\"This is an info message.\")\n\nfor i in range(100):\n    if i % 10 == 0:\n        messages.for_message(\"This is an info message inside a for loop.\")\n    messages.progress(\"This is a progress message.\", (i+1))\n    time.sleep(0.1)\n```\n\nThe result will be the following.\n\n```\n[28/08/2022 14:12:09] DEBUG [main]: This is an debug message.\n[28/08/2022 14:12:09] ERROR [main]: This is an error message.\n[28/08/2022 14:12:09] WARNING [main]: This is a warning message.\n[28/08/2022 14:12:09] SUCCESS [main]: This is a success message.\n[28/08/2022 14:14:06] SUCCESS [main]: This is a success message.\n[28/08/2022 14:12:10] INFO [main] -- This is an info message inside a for loop.\n[28/08/2022 14:12:11] INFO [main] -- This is an info message inside a for loop.\n[28/08/2022 14:12:13] INFO [main] -- This is an info message inside a for loop.\n[28/08/2022 14:12:14] INFO [main] -- This is an info message inside a for loop.\n[28/08/2022 14:12:15] INFO [main] -- This is an info message inside a for loop.\n[28/08/2022 14:12:16] INFO [main] -- This is an info message inside a for loop.\n[28/08/2022 14:12:17] INFO [main] -- This is an info message inside a for loop.\n[28/08/2022 14:12:18] INFO [main] -- This is an info message inside a for loop.\n[28/08/2022 14:12:19] INFO [main] -- This is an info message inside a for loop.\n[28/08/2022 14:12:20] INFO [main] -- This is an info message inside a for loop.\n[28/08/2022 14:14:19] INFO [main] -- This is a progress message.: [100.00%]\n```\n\n### Tasks and Processes\n\nThere are more complete classes such as `Task` and `Process` that allow\nmeasurement of execution time as well as creating subordinate verbose messages.\nBoth are equipped with all the printing function as they are inherited from the\n`VerboseMessages` class.\n\nWith `Task` it is possible to measure how long it takes to complete a execution of a function:\n\n```python\ntask1 = Task(level=5, name=\"task1\")\n\nex_time = task1.exec_time(\n    some_callable,  # Function from which measure the execution time.\n    arg1, arg2,  # Arguments of the function.\n    print_timer=True  # Print the time execution as it just return it.\n)\nex_time = task1.exec_many_time(\n    callable1, callable2, callable3,  # Functions from which measure the execution time.\n    [[f1_arg1, f1_arg2], [], [f3_arg1]], # Arguments of the functions.\n    print_timer=True  # Print the time execution as it just return it.\n)\n```\n\nAdditionally it is possible just to activate, deactivate, get the partial and\ntotal time of the timer.\n\n```python\ntask1.start_timer()\n\n# ...some code ...\nlap_time = task1.lap()\n\n# ...some code ...\ntask1.print_lap()\n\n# ...some code ...\ntask1.stop_timer()\n\ntotal_t = task1.total_time()\n```\n\nWith `Process` it is possible to create subtasks and subprocesses associated to\nit.\n\n```python\nmain_process = Process(level=5, name=\"main\")\n\nsubprocess_1: Process = main_process.new_subprocess(\"subprocess_1\")\nsubprocess_2: Process = main_process.new_subprocess(\"subprocess_2\")\nsubtask_2: Task = main_process.new_task(\"subtask_1\")\n\n# Subprocess as they are Process object, they can also create new processes and\n# tasks.\nsubsubprocess_1: Process = subprocess_1.new_subprocess(\"subsubprocess_1\")\nsubsubtask_2: Task = subprocess_1.new_task(\"subsubtask_1\")\n```\n\nAll the `Process` objects are also equipped with the timer functions as it\ninherits from the `Task` class.\n",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2022 Cindy Catalina Moreno Sarria\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.\n        ",
    "summary": "Package for colored organized verbose printing in python.",
    "version": "0.1.2.post3",
    "project_urls": null,
    "split_keywords": [
        "verbose",
        " log",
        " logger",
        " colors",
        " print"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "53d8a4e56b639caa6ef09e0bb02b97770b5d2da28f8a0d0a1e9bad06febb5399",
                "md5": "fd06f91c10c6049fd929ae95e53f13f6",
                "sha256": "3a7681454c5cbb094a6844b28ca1b20b82381f18394a82423b5b5d0994f17b34"
            },
            "downloads": -1,
            "filename": "pretty_verbose-0.1.2.post3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fd06f91c10c6049fd929ae95e53f13f6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 14259,
            "upload_time": "2025-04-15T07:43:49",
            "upload_time_iso_8601": "2025-04-15T07:43:49.214012Z",
            "url": "https://files.pythonhosted.org/packages/53/d8/a4e56b639caa6ef09e0bb02b97770b5d2da28f8a0d0a1e9bad06febb5399/pretty_verbose-0.1.2.post3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "ac7bb23bc6ae2f7a86ce76920e10b8d616fc45013e4bcb12941e31ab3424c120",
                "md5": "2029fd0e060faf24209272b26bca2e48",
                "sha256": "729553da2c56b9edf7c6e9f147f1a7c21f272b2629983fe833f50a4b7dfc75ba"
            },
            "downloads": -1,
            "filename": "pretty_verbose-0.1.2.post3.tar.gz",
            "has_sig": false,
            "md5_digest": "2029fd0e060faf24209272b26bca2e48",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 13974,
            "upload_time": "2025-04-15T07:43:50",
            "upload_time_iso_8601": "2025-04-15T07:43:50.738713Z",
            "url": "https://files.pythonhosted.org/packages/ac/7b/b23bc6ae2f7a86ce76920e10b8d616fc45013e4bcb12941e31ab3424c120/pretty_verbose-0.1.2.post3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-04-15 07:43:50",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "pretty-verbose"
}
        
Elapsed time: 0.43672s