Skip to main content

A Python library for displaying messages in the terminal with styles and logging support.

Project description

Verbose Terminal PyPI - Version PyPI - Downloads PyPI - License

Description

Verbose Terminal is a Python library that provides a simple and easy-to-use interface for displaying stylish messages in the terminal. It includes predefined styles for log, debug, info, success, warning, error and critical messages, and also has support for logging.

Requirements

  • Python 3.10+

Installation

You can install the package via pip:

pip install verbose-terminal

Usage

Import the console class from the verbose_terminal module and use its methods to print styled messages. The following examples demonstrate how to use the library:

Basic Usage

from verbose_terminal import console

# Displaying messages with different styles
console.log("This is a plain message.")
console.debug("This is a debug message.")
console.info("Here is some information.")
console.success("Operation completed successfully!")
console.warning("This is a warning message.")
console.error("An error has occurred.")
console.critical("This is a critical message.")

Verbose Flag

By default, the verbose flag is set to True. This means that the messages will be displayed on the terminal. To not display messages in the terminal, set the verbose flag to False.

from verbose_terminal import console

# Displaying messages in the terminal
console.log("This message will be displayed.")
console.log("This message will not be displayed.", verbose=False)

Logging

Verbose Terminal can also log all messages to a file, whether they are printed to the terminal or not.

Enable Logging

To enable logging, use the enable_logging method and specify a log file:

from verbose_terminal import console

# Enable logging to 'messages.log'
console.enable_logging('messages.log')

Note: Logging should be enabled only once during the application initialization. If you enable logging again in another section of your code, the last enabled logging configuration will take precedence, and messages will be logged to the new file specified in the latest enable_logging call.

from verbose_terminal import console

# Enable logging to 'initial_log.log'
console.enable_logging('initial_log.log')

# Enable logging again to 'new_log.log', this will override the previous log file
console.enable_logging('new_log.log')

In this example, all subsequent log messages will be saved to 'new_log.log', not 'initial_log.log'. Ensure you enable logging only once to avoid such conflicts.

Log flag level

By default, the log_level flag is set to INFO. Only messages will be recorded: info, success, warning, error and critical, if you want to add the debug and log messages you must pass the LOG flag

from verbose_terminal import console

# Enable logging to 'messages.log'
console.enable_logging('messages.log', log_level='LOG')

Disable Logging

To disable logging, use the disable_logging method:

from verbose_terminal import console

# Disable logging
console.disable_logging()

View Logs

To view the logs, use the view_logs method:

from verbose_terminal import console

# View logs
print(console.view_logs())

Clear Logs

To clear the logs, use the clear_logs method:

from verbose_terminal import console

# Clear logs
console.clear_logs()

Save Logs

To save the logs to a file, use the save_logs method:

from verbose_terminal import console

# Save logs to 'logs.txt'
console.save_logs('logs.txt')

Running Tests

To run the tests, run the following command:

pytest

This will execute the unit tests and display the styled messages in the terminal, allowing you to visually verify the output.

Contributing

Contributions are welcome! If you'd like to contribute, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Commit your changes and push your branch to GitHub.
  4. Submit a pull request.

Please see the CONTRIBUTING.md file for more details.

Support

Feel free to explore the code and customize the styles as per your requirements. If you encounter any issues or have suggestions for improvements, please open an issue on GitHub.

Changelog

Please see the CHANGELOG.md file for details on recent changes and releases.

License

This project is licensed under the MIT License. See the LICENSE file for more details.


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

verbose-terminal-1.0.1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

verbose_terminal-1.0.1-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file verbose-terminal-1.0.1.tar.gz.

File metadata

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

File hashes

Hashes for verbose-terminal-1.0.1.tar.gz
Algorithm Hash digest
SHA256 3284c80c45bf0cc141aca79e60a4a8217b4139a913f694624e6a8468ad29bbe8
MD5 3b2f0b4c071da03de0621b3c9d0f77fd
BLAKE2b-256 c0da78d932b1e1cea03799fdfe504933f798d5b28244b985564f363484552b34

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for verbose_terminal-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 35a417d98bb5f032f69df6344bcb5cad386394c06ceaa67e7c5d749bbf9f6bc3
MD5 710743bfaf4a966f5c77029aa073bdae
BLAKE2b-256 acd2eb91095583c96f15bd0c2c34b1407d6ce2fe0e7d5d498e64b9943ad946eb

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