Prints messages to the console
Project description
tealprint
Prints messages to the console
Features
- different verbosity levels:
none, error, warning, info, verbose, debug
- Indent messages easily under a header
- Set color using the colored package
Examples
Indentation
from tealprint import TealConfig, TealLevel, TealPrint
# Using push_indentation()
TealConfig.level = TealLevel.verbose
TealPrint.info("Header")
TealPrint.push_indent(TealLevel.info)
TealPrint.info("More information")
TealPrint.pop_indent()
# Push in header directly
TealPrint.info("Header 2", push_indent=True)
TealPrint.info("Information", push_indent=True)
TealPrint.verbose("Fine grained information")
TealPrint.pop_indent()
TealPrint.info("✅ Done")
# Skips hidden levels
TealPrint.info("Header 3", push_indent=True)
TealPrint.info("Saving all files...")
TealPrint.push_indent(TealLevel.debug)
TealPrint.debug("Saving file X") # Not displayed
TealPrint.info("Couldn't save file Y") # Only indented once, since push_indent(TealLevel.debug) was used
TealPrint.pop_indent()
TealPrint.info("✅ Saved all files")
# Same as above but with TealLevel.debug
TealConfig.level = TealLevel.debug
TealPrint.info("Header 4", push_indent=True)
TealPrint.info("Saving all files...")
TealPrint.push_indent(TealLevel.debug)
TealPrint.debug("Saving file X")
TealPrint.info("Couldn't save file Y") # Will be indented twice this time
TealPrint.pop_indent()
TealPrint.info("✅ Saved all files")
OUTPUT
Header
More information
Header 2
Information
Fine grained information
✅ Done
Header 3
Saving all files...
Couldn't save file Y
✅ Saved all files
Header 4
Saving all files...
Saving file X
Couldn't save file Y
✅ Saved all files
Color
from tealprint import TealPrint
from colored import fg, attr
TealPrint.info("Header", color=attr("bold"), push_indent=True)
TealPrint.info("OK", color=fg("green"))
OUTPUT
Automatic color for errors and warnings
from tealprint import TealPrint
TealPrint.error("Could not open file")
TealPrint.warning("Missing configuration for X")
OUTPUT
Authors
- Matteus Magnusson, senth.wallace@gmail.com
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
tealprint-0.2.0.tar.gz
(19.1 kB
view hashes)
Built Distribution
Close
Hashes for tealprint-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3487e4aa8cb5d82d3c4226c4207f18b0031a9c6e267d04f6faee688119784216 |
|
MD5 | 1bb59ca69c84dcb29d0396bd360b8846 |
|
BLAKE2b-256 | 98f56bf1c021d04db85012cfb1bc82161bf0f1fedfb2a6c4cfe8c48af959e283 |