summaryrefslogtreecommitdiffstats
path: root/combox/log.py
diff options
context:
space:
mode:
authorSiddharth Ravikumar <sravik@bgsu.edu>2015-10-17 21:31:37 -0400
committerSiddharth Ravikumar <sravik@bgsu.edu>2015-10-17 21:31:37 -0400
commitbc950b732276177c557af39575e5892bbf506cab (patch)
treec1cdc8201fca6ffacd9c1105b26d9579415cbc26 /combox/log.py
parentdf9497d7c18a6dc7e7a284b7087765ca464e8a6b (diff)
combox now uses python's logging module instead of `print` to stdout information/errors.
modified: ChangeLog modified: combox/cbox.py modified: combox/events.py modified: combox/file.py modified: combox/log.py
Diffstat (limited to 'combox/log.py')
-rw-r--r--combox/log.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/combox/log.py b/combox/log.py
index ca7f3e1..0918d9e 100644
--- a/combox/log.py
+++ b/combox/log.py
@@ -18,11 +18,26 @@
import logging
+def log_config(level, format_):
+ """Configures the logging module.
-def log_i(msg):
- """Methdod for logging information.
+ Called by all types of log functions in this module.
"""
- logging.basicConfig(level=logging.INFO,
- format='%(asctime)s - %(message)s',
+ logging.basicConfig(level=level,
+ format=format_,
datefmt='%Y-%m-%d %H:%M:%S')
+
+
+def log_i(msg, format_='%(asctime)s - %(message)s'):
+ """Function for logging information.
+ """
+ log_config(logging.INFO, format_=format_)
logging.info(msg)
+
+
+def log_e(msg, format_='%(asctime)s - %(message)s'):
+ """
+ Function for logging errors.
+ """
+ log_config(logging.ERROR, format_=format_)
+ logging.error(msg)