summaryrefslogblamecommitdiffstats
path: root/markdown_link_style/logging.py
blob: 2a93d7b728dcfc08462169a10ba08693df3b105d (plain) (tree)
1
2
3

                       
                                                       

















                                                                      
          





                                                          
                                                

                                             






                                          
                                          

                                               
                                         

                                              
                                            

                                                 
                                          

                                               
                                             

                                                  
# -*- coding: utf-8 -*-
#
#   Copyright © 2017 markdown-link-style contributors.
#
#    This file is part of markdown-link-style.
#
#   markdown-link-style is free software: you can redistribute it
#   and/or modify it under the terms of the GNU General Public License
#   as published by the Free Software Foundation, either version 3 of
#   the License, or (at your option) any later version.
#
#   markdown-link-style is distributed in the hope that it will be
#   useful, but WITHOUT ANY WARRANTY; without even the implied
#   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#   See the GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with markdown-link-style (see COPYING).  If not, see
#   <http://www.gnu.org/licenses/>.

import logging
import sys

class MDLSLogger(object):
    """Logging utility for modules in markdown-link-style.

    """

    def __init__(self, name, stream=sys.stdout):
        self.logger = logging.getLogger(name)

        # Console handler.
        sh = logging.StreamHandler(stream)
        sh.setLevel(logging.DEBUG)

        # Add handler to logger.
        self.logger.addHandler(sh)

    def debug(self, msg, *args, **kwargs):
        self.logger.debug(msg, *args, **kwargs)

    def info(self, msg, *args, **kwargs):
        self.logger.info(msg, *args, **kwargs)

    def warning(self, msg, *args, **kwargs):
        self.logger.warning(msg, *args, **kwargs)

    def error(self, msg, *args, **kwargs):
        self.logger.error(msg, *args, **kwargs)

    def critical(self, msg, *args, **kwargs):
        self.logger.critical(msg, *args, **kwargs)