forked from openlp/openlp
- fixed Bug 1086987 (Log system does not log all exceptions)
bzr-revno: 2130 Fixes: https://launchpad.net/bugs/1086987
This commit is contained in:
commit
8840df2fb2
@ -228,7 +228,7 @@ def set_up_logging(log_path):
|
|||||||
"""
|
"""
|
||||||
Setup our logging using log_path
|
Setup our logging using log_path
|
||||||
"""
|
"""
|
||||||
check_directory_exists(log_path)
|
check_directory_exists(log_path, True)
|
||||||
filename = os.path.join(log_path, u'openlp.log')
|
filename = os.path.join(log_path, u'openlp.log')
|
||||||
logfile = logging.FileHandler(filename, u'w')
|
logfile = logging.FileHandler(filename, u'w')
|
||||||
logfile.setFormatter(logging.Formatter(
|
logfile.setFormatter(logging.Formatter(
|
||||||
@ -264,13 +264,6 @@ def main(args=None):
|
|||||||
# 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()
|
||||||
if options.portable:
|
|
||||||
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')
|
|
||||||
else:
|
|
||||||
set_up_logging(AppLocation.get_directory(AppLocation.CacheDir))
|
|
||||||
qt_args = []
|
qt_args = []
|
||||||
if options.loglevel.lower() in ['d', 'debug']:
|
if options.loglevel.lower() in ['d', 'debug']:
|
||||||
log.setLevel(logging.DEBUG)
|
log.setLevel(logging.DEBUG)
|
||||||
@ -295,6 +288,10 @@ def main(args=None):
|
|||||||
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)
|
||||||
|
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
|
||||||
@ -310,6 +307,7 @@ def main(args=None):
|
|||||||
portable_settings.setValue(u'advanced/is portable', True)
|
portable_settings.setValue(u'advanced/is portable', True)
|
||||||
portable_settings.sync()
|
portable_settings.sync()
|
||||||
else:
|
else:
|
||||||
|
set_up_logging(AppLocation.get_directory(AppLocation.CacheDir))
|
||||||
app.setApplicationName(u'OpenLP')
|
app.setApplicationName(u'OpenLP')
|
||||||
app.setApplicationVersion(get_application_version()[u'version'])
|
app.setApplicationVersion(get_application_version()[u'version'])
|
||||||
# Instance check
|
# Instance check
|
||||||
|
@ -335,13 +335,17 @@ def expand_tags(text):
|
|||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
def check_directory_exists(dir):
|
def check_directory_exists(dir, do_not_log=False):
|
||||||
"""
|
"""
|
||||||
Check a theme directory exists and if not create it
|
Check a theme directory exists and if not create it
|
||||||
|
|
||||||
``dir``
|
``dir``
|
||||||
Theme directory to make sure exists
|
Theme directory to make sure exists
|
||||||
|
|
||||||
|
``do_not_log``
|
||||||
|
To not log anything. This is need for the start up, when the log isn't ready.
|
||||||
"""
|
"""
|
||||||
|
if not do_not_log:
|
||||||
log.debug(u'check_directory_exists %s' % dir)
|
log.debug(u'check_directory_exists %s' % dir)
|
||||||
try:
|
try:
|
||||||
if not os.path.exists(dir):
|
if not os.path.exists(dir):
|
||||||
|
Loading…
Reference in New Issue
Block a user