aboutsummaryrefslogtreecommitdiffstats
path: root/git_deps/utils.py
diff options
context:
space:
mode:
authorAdam Spiers <git@adamspiers.org>2016-06-29 14:47:07 +0100
committerAdam Spiers <git@adamspiers.org>2018-05-15 13:42:16 +0100
commit1385b3698a3b230368a3ad8510d2706c0930dc26 (patch)
treef1db578ab9872b605fa2dfc93936616987089686 /git_deps/utils.py
parent365dabcd8ee2cd3a18e0ce6066867d479cb60b83 (diff)
downloadgit-deps-1385b3698a3b230368a3ad8510d2706c0930dc26.tar.gz
move debug logger setup to utils.py
This is cleaner and will allow it to be reused elsewhere.
Diffstat (limited to 'git_deps/utils.py')
-rw-r--r--git_deps/utils.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/git_deps/utils.py b/git_deps/utils.py
index 3661c00..e2e1720 100644
--- a/git_deps/utils.py
+++ b/git_deps/utils.py
@@ -1,8 +1,21 @@
from __future__ import print_function
+import logging
import sys
def abort(msg, exitcode=1):
print(msg, file=sys.stderr)
sys.exit(exitcode)
+
+
+def debug_logger(name):
+ log_format = '%(asctime)-15s %(levelname)-6s %(message)s'
+ date_format = '%b %d %H:%M:%S'
+ formatter = logging.Formatter(fmt=log_format, datefmt=date_format)
+ handler = logging.StreamHandler(stream=sys.stdout)
+ handler.setFormatter(formatter)
+ logger = logging.getLogger(name)
+ logger.setLevel(logging.DEBUG)
+ logger.addHandler(handler)
+ return logger