Skip to content

Latest commit

 

History

History
54 lines (39 loc) · 1.42 KB

README.md

File metadata and controls

54 lines (39 loc) · 1.42 KB

Barometer

Barometer is a Python library that combines the simple thrill of logging with print statements with the deep satisfaction of logging with a library.

print(SUCCESS, "Hello")
print(INFO, "World!")
print(WARNING, "Foo")
print(ERR, "Bar")
print(DEBUG, "asdfghjkl;")

output

Installation

Barometer has no dependencies, so you can just download the .py file and include it in your project. Or use pip to install. You know the drill.

pip install barometer

Usage

from barometer import *

@barometer
def print_two_strings(s1, s2):
    print(DEBUG, f"Concatenating {s1} and {s2})        # Add a debug level message
    try:
        result = s1 + s2
    except TypeError:
        print(ERR, "s1 and s2 must both be strings!")   # Add an error level message
    else:
        print(SUCCESS, "concatenated s1 and s2!")       # Add a success level message
        print(result)                                   # Print normally

# Default: Print non-debug log messages
print_two_strings("hello", "world")

# Print error messages and log everything to file                
print_two_string("hello", 100, log_level=DEBUG, filename="mylog.txt", verbosity=ERR)

# Just log to file
print_two_strings("hello", "world", log_level=DEBUG, filename="mylog.txt", verbosity=None)

License

MIT