Skip to main content

A simple logging package

Project description

log21

version stars forks repo size CodeFactor

A simple logging package that helps you log colorized messages in Windows console and other operating systems.

Features

  • Colors : The main reason for this package was to log text in the Windows console with the support of ANSI colors.
  • Argument parsing : log21's argument parser can be used like python's argparse, but it also colorizes the output.
  • Logging : A similar logger to logging. Logger but with colorized output and other options such as levelname modifications. It can also decolorize the output if you want to log into a file.
  • Pretty printing : Have you ever wanted to colorize the output of the pprint module? log21's pretty printer can do that.
  • Tree printing : You can pass a dict or list to log21.tree_print function, and it will print it in a tree-like structure. It's also colorized XD.
  • ProgressBar : log21's progress bar can be used to show progress of a process in a beautiful way.
  • LoggingWindow : Helps you to log messages and debug your code in a window other than the console.
  • CrashReporter : log21's crash reporter can be used to report crashes in different ways. You can use it to log crashes to console or files or use it to receive crash reports of your program through email. And you can also define your own crash reporter functions and use them instead!
  • Argumentify : You can use the argumentify feature to decrease the number of lines you need to write to parse command-line arguments. It's colored by the way!
  • Any idea? Feel free to open an issue or submit a pull request.

Issues contributors

Installation

Well, this is a python package so the first thing you need is python.

If you don't have python installed, please visit Python.org and install the latest version of python.

Then you can install log21 using pip module:

python -m pip install log21 -U

Or you can clone the repository and run:

pip install .

Or let the pip get it using git:

pip install git+https://github.com/MPCodeWriter21/log21

Changelog

v3.3.1

Get rid of invalid NoneType value error message.

In the previous versions, if you used an optional union type such as int | float | None which ended with None, you'd get an error saying invalid NoneType value that didn't make any sense to the user. The code has been updated to use the name of the last non-None type for the error message in these situations.

Example

import log21
from log21.helper_types import FileSize


def main(min_size: FileSize | None = None, max_size: FileSize | None = None) -> None:
    log21.info("Min Size: %s, Max Size: %s", args=(min_size, max_size))

if __name__ == "__main__":
    log21.argumentify(main)

Before v3.3.1:

$ python test.py -m Hello
usage: test.py [-h] [--min-size MIN_SIZE] [--max-size MAX_SIZE]

test.py: error: argument --min-size/-m: invalid NoneType value: 'Hello'

With v3.3.1 update:

$ python test.py -m Hello
usage: test.py [-h] [--min-size MIN_SIZE] [--max-size MAX_SIZE]

test.py: error: argument --min-size/-m: invalid FileSize value: 'Hello'

Full CHANGELOG

Usage Examples

See EXAMPLES.md

About

Author: CodeWriter21 (Mehrad Pooryoussof)

GitHub: MPCodeWriter21

Telegram Channel: @CodeWriter21

License

License

apache-2.0

Donate

In order to support this project you can donate some crypto of your choice 8D

Donate Addresses

Or if you can't, give this project a star on GitHub :)

References

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

log21-3.3.1.tar.gz (79.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

log21-3.3.1-py3-none-any.whl (87.6 kB view details)

Uploaded Python 3

File details

Details for the file log21-3.3.1.tar.gz.

File metadata

  • Download URL: log21-3.3.1.tar.gz
  • Upload date:
  • Size: 79.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for log21-3.3.1.tar.gz
Algorithm Hash digest
SHA256 2c6a81e7936d94384059b3505bf1a79ed58eb6e84821a994ffb6d0cb13be51ff
MD5 b3c6c2718f0f12ed3f6016e3ce2e0dfe
BLAKE2b-256 5c1ea0ee3ea5fdbb51d38d6b4b9287a2df24273007f1722f64a44fc5debd67aa

See more details on using hashes here.

File details

Details for the file log21-3.3.1-py3-none-any.whl.

File metadata

  • Download URL: log21-3.3.1-py3-none-any.whl
  • Upload date:
  • Size: 87.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for log21-3.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0fad2628f4e204e7d7ee0e0f7e399e2db9798912d516d7abe3ce937b7551ea5e
MD5 d4836e82f0b20b9545cba5f0fa7357a5
BLAKE2b-256 765da1728165bab39d8fdbaca40b2d78d5da46cb9d135ae65896c772b5e585a4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page