root/trunk/libffado/support/mixer-qt4/ffado/logginghandler.py

Revision 2802, 2.3 kB (checked in by jwoithe, 3 years ago)

Cosmetic: "Firewire" becomes "FireWire?".

Officially both the "F" and "W" were capitalised in the FireWire? name, so
reflect this throughout FFADO's source tree. This mostly affects comments.

This patch originated from pander on the ffado-devel mailing list. To
maintain consistency, the committed version has been expanded to include
files not originally included in the original patch.

  • Property svn:mergeinfo set to
Line 
1 #
2 # Copyright (C) 2008 by Arnold Krille
3 #
4 # This file is part of FFADO
5 # FFADO = Free FireWire (pro-)audio drivers for linux
6 #
7 # FFADO is based upon FreeBoB.
8 #
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 #
22
23 # from PyQt4.QtGui import QTextEdit, QAbstractSlider, QColor
24 # from PyQt4.QtCore import QObject, pyqtSignal, QString
25 from ffado.import_pyqt import *
26
27 import logging
28 log = logging.getLogger('logginghandler')
29
30 class QStatusLogger( QObject, logging.Handler ):
31     log = pyqtSignal(QString if ffado_pyqt_version == 4 else str, int, name='log')
32     def __init__( self, parent, statusbar, level=logging.NOTSET ):
33         QObject.__init__( self, parent )
34         logging.Handler.__init__( self, level )
35         self.setFormatter( logging.Formatter( "%(name)s: %(message)s" ) )
36         self.log.connect(statusbar.showMessage)
37
38     def emit( self, record ):
39         self.log.emit('%s: %s'.format(record.name, record.getMessage()), 5000)
40
41 class QTextLogger( logging.Handler ):
42     def __init__( self, parent, level=logging.NOTSET ):
43         logging.Handler.__init__( self, level )
44
45         self.textedit = QTextEdit( parent )
46
47         self.textedit.setReadOnly( True )
48         self.textedit.setAcceptRichText( True )
49
50     def emit( self, record ):
51         color = QColor( "#000000" )
52         if record.levelno > 20:
53             color = QColor( "#ffff00" )
54         if record.levelno > 30:
55             color = QColor( "#ff0000" )
56         if record.levelno <= 10:
57             color = QColor( "#808080" )
58         self.textedit.setTextColor( color )
59         tmp = "%s %s: %s" % (record.asctime, record.name, record.getMessage())
60         self.textedit.append( tmp )
61         self.textedit.verticalScrollBar().triggerAction( QAbstractSlider.SliderToMaximum )
62
63 #
64 # vim: et
65 #
Note: See TracBrowser for help on using the browser.