forked from openlp/openlp
Added code to put logfile into portableapp-dir/other if running portable.
bzr-revno: 2028 Fixes: https://launchpad.net/bugs/1020068
This commit is contained in:
commit
2e693c0d52
@ -207,6 +207,16 @@ class OpenLP(QtGui.QApplication):
|
|||||||
else:
|
else:
|
||||||
return QtGui.QApplication.event(self, event)
|
return QtGui.QApplication.event(self, event)
|
||||||
|
|
||||||
|
def set_up_logging(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):
|
def main(args=None):
|
||||||
"""
|
"""
|
||||||
@ -231,14 +241,6 @@ def main(args=None):
|
|||||||
help='Set the Qt4 style (passed directly to Qt4).')
|
help='Set the Qt4 style (passed directly to Qt4).')
|
||||||
parser.add_option('--testing', dest='testing',
|
parser.add_option('--testing', dest='testing',
|
||||||
action='store_true', help='Run by testing framework')
|
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.
|
# Parse command line options and deal with them.
|
||||||
# Use args supplied programatically if possible.
|
# Use args supplied programatically if possible.
|
||||||
(options, args) = parser.parse_args(args) if args else parser.parse_args()
|
(options, args) = parser.parse_args(args) if args else parser.parse_args()
|
||||||
@ -261,11 +263,13 @@ def main(args=None):
|
|||||||
app.setOrganizationName(u'OpenLP')
|
app.setOrganizationName(u'OpenLP')
|
||||||
app.setOrganizationDomain(u'openlp.org')
|
app.setOrganizationDomain(u'openlp.org')
|
||||||
if options.portable:
|
if options.portable:
|
||||||
log.info(u'Running portable')
|
|
||||||
app.setApplicationName(u'OpenLPPortable')
|
app.setApplicationName(u'OpenLPPortable')
|
||||||
Settings.setDefaultFormat(Settings.IniFormat)
|
Settings.setDefaultFormat(Settings.IniFormat)
|
||||||
# Get location OpenLPPortable.ini
|
# Get location OpenLPPortable.ini
|
||||||
app_path = AppLocation.get_directory(AppLocation.AppDir)
|
app_path = AppLocation.get_directory(AppLocation.AppDir)
|
||||||
|
set_up_logging(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'..',
|
portable_settings_file = os.path.abspath(os.path.join(app_path, u'..',
|
||||||
u'..', u'Data', u'OpenLP.ini'))
|
u'..', u'Data', u'OpenLP.ini'))
|
||||||
# Make this our settings file
|
# Make this our settings file
|
||||||
@ -282,6 +286,7 @@ def main(args=None):
|
|||||||
portable_settings.sync()
|
portable_settings.sync()
|
||||||
else:
|
else:
|
||||||
app.setApplicationName(u'OpenLP')
|
app.setApplicationName(u'OpenLP')
|
||||||
|
set_up_logging(AppLocation.get_directory(AppLocation.CacheDir))
|
||||||
app.setApplicationVersion(get_application_version()[u'version'])
|
app.setApplicationVersion(get_application_version()[u'version'])
|
||||||
# Instance check
|
# Instance check
|
||||||
if not options.testing:
|
if not options.testing:
|
||||||
|
Loading…
Reference in New Issue
Block a user