Fix up logging so it works

This commit is contained in:
Tim Bentley 2009-08-31 09:39:19 +01:00
parent 658216535c
commit c35c26b866

View File

@ -30,10 +30,14 @@ from openlp.core.resources import *
from openlp.core.ui import MainWindow, SplashScreen from openlp.core.ui import MainWindow, SplashScreen
filename=u'openlp.log' filename=u'openlp.log'
log = logging.getLogger()
log.setLevel(logging.INFO)
logfile = logging.handlers.TimedRotatingFileHandler(filename , 'midnight', 1, backupCount=5) logfile = logging.handlers.TimedRotatingFileHandler(filename , 'midnight', 1, backupCount=5)
logfile.setLevel(logging.INFO) logfile.setLevel(logging.DEBUG)
logfile.setFormatter(logging.Formatter(u'%(asctime)s:%(msecs)3d %(name)-15s %(levelname)-8s %(message)s')) logfile.setFormatter(logging.Formatter(u'%(asctime)s:%(msecs)3d %(name)-15s %(levelname)-8s %(message)s'))
logging.getLogger().addHandler(logfile)
log.addHandler(logfile)
class OpenLP(QtGui.QApplication): class OpenLP(QtGui.QApplication):
""" """
@ -41,8 +45,7 @@ class OpenLP(QtGui.QApplication):
class in order to provide the core of the application. class in order to provide the core of the application.
""" """
global log global log
log = logging.getLogger(u'OpenLP Application') log.info(u'OpenLP Application Loaded')
log.info(u'Application Loaded')
def run(self): def run(self):
""" """
@ -84,7 +87,7 @@ def main():
help="Switch on Debugging ") help="Switch on Debugging ")
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
if options.debug is not None: if options.debug is not None:
logfile.setLevel(logging.DEBUG) log.setLevel(logging.DEBUG)
if __name__ == u'__main__': if __name__ == u'__main__':
""" """
Instantiate and run the application. Instantiate and run the application.