SF.net SVN: fclient: [575] trunk/fclient/src/fclient/Ui_ViewLogger.py
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-07-11 16:33:31
|
Revision: 575
http://fclient.svn.sourceforge.net/fclient/?rev=575&view=rev
Author: jUrner
Date: 2008-07-11 09:33:36 -0700 (Fri, 11 Jul 2008)
Log Message:
-----------
too many changes to list
Modified Paths:
--------------
trunk/fclient/src/fclient/Ui_ViewLogger.py
Modified: trunk/fclient/src/fclient/Ui_ViewLogger.py
===================================================================
--- trunk/fclient/src/fclient/Ui_ViewLogger.py 2008-07-11 16:33:29 UTC (rev 574)
+++ trunk/fclient/src/fclient/Ui_ViewLogger.py 2008-07-11 16:33:36 UTC (rev 575)
@@ -3,6 +3,9 @@
if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below
import os; __path__ = [os.path.dirname(__file__)]
+import logging
+import sys
+logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
from PyQt4 import QtGui
@@ -14,21 +17,56 @@
#**********************************************************************************
#
#**********************************************************************************
+class Settings(config.SettingsBase):
+
+ _key_ = config.IdViewLoggerWidget
+ _settings_ = (
+ ('MaxLines', 'UInt', 1000),
+ )
+
#***********************************************************************
#
#***********************************************************************
class ViewLoggerWidget(QtGui.QWidget, Ui_ViewLoggerWidget):
- def __init__(self, parent, cfg=None):
- QtGui.QWidget.__init__(self, parent)
+ IdEddLogger = 'edLogger'
+
+ class MyLoggingHandler(logging.Handler):
+ def __init__(self, myLogf, *args, **kwargs):
+ logging.Handler.__init__(self, *args, **kwargs)
+ self.myLogf = myLogf
- self.cfg = config.Config(self) if cfg is None else cfg
+ def emit(self, record):
+ self.myLogf(
+ '%s:%s:%s' % (record.levelname, record.name, record.getMessage())
+ )
+
+
+ def __init__(self, parent, cfg=None, level=logging.NOTSET):
+ QtGui.QWidget.__init__(self, parent)
+ self.settings = Settings()
-
self.setupUi(self)
config.ObjectRegistry.register(self)
-
+
+ self.settings.restore()
+ ed = self.controlById(self.IdEddLogger)
+ ed.document().setMaximumBlockCount(self.settings.value('MaxLines'))
+
+ self.loggingHandler = self.MyLoggingHandler(self.addMessage)
+ logging.getLogger('').addHandler(self.loggingHandler)
+
+
+ def controlById(self, idControl):
+ return getattr(self, idControl)
+
+ def addMessage(self, text):
+ print text, type(text)
+
+ ed = self.controlById(self.IdEddLogger)
+ ed.append(text)
+
#**********************************************************************************
#
#**********************************************************************************
@@ -36,7 +74,7 @@
def __init__(self):
self._widget = None
-
+
def displayName(self):
return QtGui.QApplication.translate("ViewLogger", "Logger", None, QtGui.QApplication.UnicodeUTF8)
@@ -51,7 +89,9 @@
if self._widget is None:
self._widget = ViewLoggerWidget(parent)
return self._widget
-
+
+ def close(self):
+ pass
#**********************************************************************************
#
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|