diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..89e853a535434f3dddb6836d2dcf0a75b8217c32 --- /dev/null +++ b/README.md @@ -0,0 +1,34 @@ +# Development Utils + +## Colored logger + +#### What? +Bunch of patches for python logging: + - add colors + - change `stderr` stream (default everywhere) to `stdout` + +#### Why? +Because you don't want to see everything in red in your IDE + +#### How? +Add the following piece of code: + - in django - to your `settings/dev.py` (or wherever your dev settings are) + - in other projects - anywhere where it will be executed somewhat early (like top of the file) + +``` +try: # Colored logger CaaS. Auto downloaded and verified. + import os + import hashlib + from urllib import request + cache, url = "/tmp/_colored_logger.py", "https://lab.it.hs-hannover.de/lukyanch/pydevutils/raw/140726c2cb35dd5f770c4bde86fee3f5d61348b6/colored_logger.py" + code = bool(os.path.exists(cache) or request.urlretrieve(url, cache)) and open(cache, "r").read() + assert hashlib.sha256(code.encode()).hexdigest() == "d4d261a40f95733f9fb184fc4ccb55d007b880cb62c8d6a06824d43eeb1391ac", "unrecognized content in" + cache + exec(code) +except Exception as e: + print("No colored logger: {e.__class__.__name__}: {e}".format(e=e)) +``` + +# Safe? +Quite safe. The downloaded file is only executed if its SHA256 matches the expected value. + +