openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #16528
[Merge] lp:~elderp/openlp/logfile-bug-1020068 into lp:openlp
Stevan Pettit has proposed merging lp:~elderp/openlp/logfile-bug-1020068 into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~elderp/openlp/logfile-bug-1020068/+merge/113855
Added code to put logfile into portableapp-dir/other if running portable.
--
https://code.launchpad.net/~elderp/openlp/logfile-bug-1020068/+merge/113855
Your team OpenLP Core is requested to review the proposed merge of lp:~elderp/openlp/logfile-bug-1020068 into lp:openlp.
=== modified file 'openlp/core/__init__.py'
--- openlp/core/__init__.py 2012-06-22 14:14:53 +0000
+++ openlp/core/__init__.py 2012-07-08 12:59:19 +0000
@@ -207,6 +207,16 @@
else:
return QtGui.QApplication.event(self, event)
+def setupLogging(log_path):
+ """
+ Setup our logging using log_path
+ """
+ check_directory_exists(log_path)
+ filename = os.path.join(log_path, u'openlp.log')
+ logfile = logging.FileHandler(filename, u'w')
+ logfile.setFormatter(logging.Formatter(
+ u'%(asctime)s %(name)-55s %(levelname)-8s %(message)s'))
+ log.addHandler(logfile)
def main(args=None):
"""
@@ -231,14 +241,6 @@
help='Set the Qt4 style (passed directly to Qt4).')
parser.add_option('--testing', dest='testing',
action='store_true', help='Run by testing framework')
- # Set up logging
- log_path = AppLocation.get_directory(AppLocation.CacheDir)
- check_directory_exists(log_path)
- filename = os.path.join(log_path, u'openlp.log')
- logfile = logging.FileHandler(filename, u'w')
- logfile.setFormatter(logging.Formatter(
- u'%(asctime)s %(name)-55s %(levelname)-8s %(message)s'))
- log.addHandler(logfile)
# Parse command line options and deal with them.
# Use args supplied programatically if possible.
(options, args) = parser.parse_args(args) if args else parser.parse_args()
@@ -261,11 +263,13 @@
app.setOrganizationName(u'OpenLP')
app.setOrganizationDomain(u'openlp.org')
if options.portable:
- log.info(u'Running portable')
app.setApplicationName(u'OpenLPPortable')
Settings.setDefaultFormat(Settings.IniFormat)
# Get location OpenLPPortable.ini
app_path = AppLocation.get_directory(AppLocation.AppDir)
+ setupLogging(os.path.abspath(os.path.join(app_path, u'..',
+ u'..', u'Other')))
+ log.info(u'Running portable')
portable_settings_file = os.path.abspath(os.path.join(app_path, u'..',
u'..', u'Data', u'OpenLP.ini'))
# Make this our settings file
@@ -282,6 +286,8 @@
portable_settings.sync()
else:
app.setApplicationName(u'OpenLP')
+ # Set up logging
+ setupLogging(AppLocation.get_directory(AppLocation.CacheDir))
app.setApplicationVersion(get_application_version()[u'version'])
# Instance check
if not options.testing:
Follow ups