diff options
Diffstat (limited to 'markdown/md_logging.py')
-rw-r--r-- | markdown/md_logging.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/markdown/md_logging.py b/markdown/md_logging.py new file mode 100644 index 0000000..463be15 --- /dev/null +++ b/markdown/md_logging.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +import logging +from logging import DEBUG, INFO, WARN, ERROR, CRITICAL +import sys +import warnings + +# +# Exceptions +# + +class MarkdownException(Exception): + """ A Markdown Exception. """ + pass + + +class MarkdownWarning(Warning): + """ A Markdown Warning. """ + pass + + +# +# Global functions +# + +def message(level, text): + """ A wrapper method for logging debug messages. """ + logger = logging.getLogger('MARKDOWN') + if logger.handlers: + # The logger is configured + logger.log(level, text) + if level > WARN: + sys.exit(0) + elif level > WARN: + raise MarkdownException, text + else: + warnings.warn(text, MarkdownWarning)
\ No newline at end of file |