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.0.1

Fix the issue with argumentify which would result in falsy default values to be replaced with None.

  • Example:
def main(offset: int = 0) -> None:
    ...

argumentify(main)

if no value is provided for --offset, the default will be None instead of 0 which is unexpected and can lead to issues.

Breaking Changes

  • Internal module renaming and normalization

    • All internal modules were renamed to lowercase and, in some cases, split or reorganized.
    • Imports such as log21.Colors, log21.Logger, log21.ProgressBar, etc. are no longer valid.
    • Users importing from internal modules must update their imports to the new module names.
    • Public imports from log21 remain supported.
  • Argumentify exception renames

    • Several exceptions were renamed to follow a consistent *Error naming convention:
      • TooFewArgumentsTooFewArgumentsError
      • RequiredArgumentRequiredArgumentError
      • IncompatibleArgumentsIncompatibleArgumentsError
    • Code that explicitly raises or catches these exceptions must be updated.

Changes

  • Crash reporter behavior improvement

    • Prevented the default file crash reporter from creating .crash_report files when it is not actually used.
    • Implemented using an internal FakeModule helper.
  • Argparse compatibility update

    • Bundled and used the Python 3.13 argparse implementation to ensure consistent behavior across supported Python versions.
  • Progress bar module rename

    • Renamed the internal progress bar module to progress_bar for consistency with the new naming scheme.
    • This will not break the usages of log21.progress_bar(...) since the call functionality was added to the module using the FakeModule helper.
  • Examples added and updated

    • Added new example code files.
    • Updated existing examples to match the v3 API and conventions.

Fixes

  • Resolved various linting and static-analysis issues across the codebase.
  • Addressed minor compatibility issues uncovered by running linters and pre-commit hooks.
  • Resolved errors occurring in environments with newer versions of argparse.

Internal and Maintenance Changes

  • Migrated the build system configuration to uv.
  • Updated Python version classifiers and set the supported Python version to 3.9+.
  • Added vermin to the pre-commit configuration.
  • Updated .gitignore, license metadata, and tool configurations.
  • Silenced and resolved a large number of linter warnings.
  • General internal refactoring with no intended user-visible behavioral changes.

Notes

  • There are no intentional behavioral changes in logging output, argument parsing logic, or UI components.
  • Most projects will require minimal or no changes unless they depend on internal modules or renamed exceptions.
  • See MIGRATION-V2-V3.md for detailed upgrade instructions.

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.0.1.tar.gz (78.9 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.0.1-py3-none-any.whl (86.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for log21-3.0.1.tar.gz
Algorithm Hash digest
SHA256 53d99f22de14049eabdf2700515f3ede025f68a27293d2411cd0cae0a1d60e8e
MD5 27083ad86dff02435665a4a2e60d79a0
BLAKE2b-256 61e977e9bc0146cec4e4559cf01aca7d3c08965a339695fc63f0982fe989e0a6

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for log21-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4da0a89eac70645aa639ed466a9fa7e189e27e500c4072da15cb562361fe8e86
MD5 7fda615603a45e9e545336de04788efd
BLAKE2b-256 dac8b58abf370fe43ebe26b4cc07e0d452f2b77c6e7ed770aaa5ea8adaddc58f

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