Skip to content

Simple Python library for logging using decorators and print statements

Notifications You must be signed in to change notification settings

cameron-toy/barometer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Simple Python library for logging using decorators and print statements

Resources

Stars

Watchers

Forks

Packages

 
 
 

Languages