summaryrefslogtreecommitdiff
path: root/Biz/Log.py
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2023-08-28 21:05:25 -0400
committerBen Sima <ben@bsima.me>2023-09-20 17:56:12 -0400
commit6e4a65579c3ade76feea0890072099f0d0caf416 (patch)
tree95671321c951134753323978854cece5f7d5435b /Biz/Log.py
parent13added53bbf996ec25a19b734326a6834918279 (diff)
Prototype Mynion
This implements a prototype Mynion, my chatbot which will eventually help me write code here. In fact he's already helping me, and works pretty well over xmpp. The prompt is currently not checked in because I'm experimenting with it a lot, and it should probably be a runtime parameter anyways. In the course of writing this I added some helper libraries to get me going, configured black (didn't even know that was possible), and added 'outlines' and its dependencies even though I didn't end up using it. I'll keep outlines around for now, but I'm not sure how useful it really is because afaict its just pre-defining some stop conditions. But it took a while to get it working so I'll just keep it in for now.
Diffstat (limited to 'Biz/Log.py')
-rw-r--r--Biz/Log.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/Biz/Log.py b/Biz/Log.py
new file mode 100644
index 0000000..af28c41
--- /dev/null
+++ b/Biz/Log.py
@@ -0,0 +1,32 @@
+"""
+Setup logging like Biz/Log.hs.
+"""
+
+import logging
+import typing
+
+
+class LowerFormatter(logging.Formatter):
+ def format(self, record: typing.Any) -> typing.Any:
+ record.levelname = record.levelname.lower()
+ return super(logging.Formatter, self).format(record) # type: ignore
+
+
+def setup() -> None:
+ "Run this in your __main__ function"
+ logging.basicConfig(
+ level=logging.DEBUG, format="%(levelname)s: %(name)s: %(message)s"
+ )
+ logging.addLevelName(logging.DEBUG, "dbug")
+ logging.addLevelName(logging.ERROR, "fail")
+ logging.addLevelName(logging.INFO, "info")
+ logger = logging.getLogger(__name__)
+ formatter = LowerFormatter()
+ handler = logging.StreamHandler()
+ handler.setFormatter(formatter)
+ logger.addHandler(handler)
+
+
+if __name__ == "__main__":
+ setup()
+ logging.debug("i am doing testing")