linkchecker/linkcheck/gui/logger.py

57 lines
1.7 KiB
Python
Raw Normal View History

# -*- coding: iso-8859-1 -*-
2010-09-29 06:25:00 +00:00
# Copyright (C) 2009-2010 Bastian Kleineidam
#
# 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.
#
2009-07-24 21:58:20 +00:00
# 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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
from logging import Handler
from ..logger import Logger
class GuiLogHandler (Handler, object):
2009-02-24 20:51:44 +00:00
"""Delegate log messages to the UI."""
2010-11-18 22:26:34 +00:00
def __init__ (self, signal):
2009-02-24 20:51:44 +00:00
"""Save widget."""
super(GuiLogHandler, self).__init__()
2010-11-18 22:26:34 +00:00
self.signal = signal
def emit (self, record):
2010-10-14 19:13:28 +00:00
"""Emit a record. It gets logged in the debug widget."""
2010-11-18 22:26:34 +00:00
self.signal.emit(self.format(record))
class GuiLogger (Logger):
2010-09-28 18:20:08 +00:00
"""Delegate log URLs to the UI tree widget."""
def __init__ (self, **args):
super(GuiLogger, self).__init__(**args)
2010-11-18 22:26:34 +00:00
self.log_url_signal = args["signal"]
def start_fileoutput (self):
pass
def close_fileoutput (self):
pass
def log_url (self, url_data):
2009-02-24 20:51:44 +00:00
"""URL gets logged in the main window."""
2010-11-18 22:26:34 +00:00
self.log_url_signal.emit(url_data)
def end_output (self):
pass
def start_output (self):
pass