Created
April 16, 2019 01:09
-
-
Save busybus/9d8e3ddcfbcfceafc26d1f730b7a0df2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# AUXILIARY: | |
# https://stackoverflow.com/questions/34491808/how-to-get-the-current-scripts-code-in-python | |
THIS = inspect.getsource(inspect.getmodule(inspect.currentframe())) | |
# Set logger verbosity and output format | |
logging.basicConfig( | |
level=logging.DEBUG, | |
format="%(levelname)-8s [%(asctime)s] : %(message)s", | |
datefmt="%Y%m%d %H:%M:%S %Z" | |
) | |
# Log which files are opened | |
def logged_open(filename, mode='r', *argv, **kwargs): | |
from builtins import open as builtin_open | |
logging.info("({}):\t{}".format(mode, filename)) | |
return builtin_open(filename, mode, *argv, **kwargs) | |
open = logged_open |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment