# vim: set fileencoding=utf-8 : # # (C) 2010 Guido Guenther <agx@sigxcpu.org> # This program 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 2 of the License, or # (at your option) any later version. # # This program 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 this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #
'magenta', 'cyan', 'white'], range(30, 38))) INFO: COLORS['green'], WARNING: COLORS['red'], ERROR: COLORS['red'], CRITICAL: COLORS['red']}
"""Filter for enabling selective output"""
"""Do we show the record"""
"""Special stream handler for enabling colored output"""
"""Set/unset colorized output""" self._color = gbp.tristate.Tristate(color)
"""Set logging colors""" self._color_scheme = DEFAULT_COLOR_SCHEME.copy() self._color_scheme.update(color_scheme)
"""Set logging format""" self.setFormatter(logging.Formatter(fmt=fmt))
"""Check if to print in color or not""" return True os.getenv("INSIDE_EMACS", "").endswith(",comint")) return False
"""Colorizing formatter"""
"""Logger class for git-buildpackage"""
GbpStreamHandler(sys.stderr, color)] CRITICAL]))
"""Set/unset colorized output of the default handlers""" for hdlr in self._default_handlers: hdlr.set_color(color)
"""Set the color scheme of the default handlers""" for hdlr in self._default_handlers: hdlr.set_color_scheme(color_scheme)
"""Set the format of the default handlers""" for hdlr in self._default_handlers: hdlr.set_format(fmt)
"""Logs a message with level ERROR on the GBP logger""" LOGGER.error(msg)
"""Logs a message with level WARNING on the GBP logger""" LOGGER.warning(msg)
"""Logs a message with level INFO on the GBP logger""" LOGGER.info(msg)
"""Logs a message with level DEBUG on the GBP logger"""
"""Set logging colors""" scheme = {} colors = color_scheme.split(':') levels = (DEBUG, INFO, WARNING, ERROR)
if color_scheme and len(colors) != len(levels): raise ValueError("Number color fields in color scheme not %d'" % len(levels))
for field, color in enumerate(colors): level = levels[field] try: scheme[level] = int(color) except ValueError: try: scheme[level] = COLORS[color.lower()] except KeyError: pass return scheme
"""Basic logger setup""" LOGGER.set_color(color) LOGGER.set_color_scheme(_parse_color_scheme(color_scheme)) if verbose: LOGGER.setLevel(DEBUG) else: LOGGER.setLevel(INFO)
# Initialize the module
|