Skip to main content

A Python package that provides a convenient print-like function for logging messages with various log levels, making it easy to integrate logging into your projects.

Project description

printx

printx is a Python package that provides a convenient print-like function for logging messages with various log levels, making it easy to integrate logging into your projects.

Installation

You can install printx via pip:

pip install printx

Usage

from printx import printx_configure, printx

# Configure logging (optional: specify a custom log filename)
printx_configure()

# Use the printx function
printx("This is a default info message")
printx("This is a debug message", log_level='debug')
printx("This is an info message", log_level='info')
printx("This is a warning message", log_level='warning')
printx("This is an error message", log_level='error')
printx("This is a critical message", log_level='critical')

def example_function():
    try:
        printx("Starting the function")
        printx("Performing an action")
        error_condition = True  # Simulate an error condition
        if error_condition:
            raise ValueError("An error occurred")
        printx("Function finished")
    except Exception as e:
        printx(f"Exception occurred: {e}", log_level='error')

example_function()

Configuration

The printx_configure function allows you to configure the logging settings. By default, it logs messages to a file named after the script that uses the printx function and to the console.

To configure logging:

from printx import printx_configure

Configure logging with default settings

printx_configure()

Configure logging with a custom log filename

printx_configure(log_filename='custom_log.log')

Configure logging with a different log level

printx_configure(level=logging.WARNING)

The printx_configure function accepts the following parameters:

  • log_filename (str, optional): The name of the log file. If not provided, the default is the script's name with a .log extension.
  • level (int, optional): The logging level. Default is logging.DEBUG.

License

This project is licensed under the MIT License.

Contributing

Contributions are welcome! Please fork the repository and submit a pull request.

Author

Javer Valino

Acknowledgments

  • Thanks to the open-source community for providing the tools and inspiration for this project.
  • Special thanks to all contributors and users of the package.

Project details


Download files

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

Source Distribution

printx-1.0.1.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

printx-1.0.1-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

Details for the file printx-1.0.1.tar.gz.

File metadata

  • Download URL: printx-1.0.1.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.11

File hashes

Hashes for printx-1.0.1.tar.gz
Algorithm Hash digest
SHA256 710dce9f4730abda61ea784048f57a8f07446dcb5a1cc3302ed0f76d8ce2b9f3
MD5 fe366064efb56daf92aeec65b5d10897
BLAKE2b-256 7e158e09a3e47cbe0147b37a724d8ec5b95aa59d50f259bcd3ec1d74cf4045b0

See more details on using hashes here.

File details

Details for the file printx-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: printx-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 2.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.11

File hashes

Hashes for printx-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2057d9968cc10c8aaea15c257349577b8c4e10537be730c530559c5469775846
MD5 7cf7eb8910394c1be09ac8374e52dc49
BLAKE2b-256 c632c2cc34ec4eef602d529b729c1879d6e2e75708a66bd798fe7e8f22a534a3

See more details on using hashes here.

Supported by

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