logeverywhere 0.0.1
log-everywhere Python API
Installing the package
Enter the following in your command line:
# if something isn't working properly, try rerunning this
# the problem may have been fixed with a newer version
pip3 install -U log-everywhere # MacOS/Linux
pip install -U log-everywhere # Windows
Using the log-everywhere package
python3 # MacOS/Linux
python # Windows
from log_everywhere import yield_logger
from log_everywhere import log
def do_important_things(log_locations):
num = 1 + 1
log(f'This function calculated num to be: {num}', log_locations)
product = num * 2
log(f'This function calculated the product of num multiplied by 2 to be: {product}', log_locations)
log( 'This function is now closing...', log_locations)
def main():
with yield_logger('name_of_my_log_file', log_silently=False) as log_locations:
do_important_things(log_locations)
main()
To see why Python Standard Library's logging module was insufficient and creating a custom logger was necessary, see this modification in the yt_videos_list package. NOTE that the exact implementation differed slighlty in this commit (yield_logger() was named yield_file_writer()), and support for logging to both the console AND the log file wasn't added until this commit
Direct link to commits:
Simplify logging via custom context manager text writer
Always log to log file but allow console logging muting
To see more interesting logging modifications, see the significantly improves logging section nested within the details section of the yt_videos_list package 0.5.0 Release page!
Seeing all available functions for the log-everywhere package
python3 # MacOS/Linux
python # Windows
import log_everywhere
help(log_everywhere.logger)
# OR
from log_everywhere import logger
help(logger)
# SEEING PACKAGE METADATA
import log_everywhere
help(log_everywhere)
Usage Statistics
PePy
PyPi Stats
If you found this interesting or useful, please consider starring this repo on GitHub so other people can more easily find and use this. Thanks!
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.