Commits

David McClosky committed f793b0e

Add get_simple_logger()

Comments (0)

Files changed (1)

waterworks/Tools.py

         return cmp(self._key(), other_key)
     def _key(self):
         raise NotImplementedError("Must implement _key() method.")
+
+def get_simple_logger(name):
+    import logging
+
+    # create logger
+    logger = logging.getLogger(name)
+    logger.setLevel(logging.DEBUG)
+
+    # create console handler and set level to debug
+    ch = logging.StreamHandler()
+    ch.setLevel(logging.DEBUG)
+
+    # create formatter
+    formatter = logging.Formatter("%(asctime)s %(name)s %(levelname)s: %(message)s")
+
+    # add formatter to ch
+    ch.setFormatter(formatter)
+
+    # add ch to logger
+    logger.addHandler(ch)
+    return logger