Move the icu missing warning to after setting up the log handler.
(cherry picked from commit 6eb76c8af59ee15f618b44c0755bbdde4f72e222)
This commit is contained in:
parent
bd23fce194
commit
89e394a690
@ -36,6 +36,7 @@ import logging
|
|||||||
LOG = logging.getLogger("." + __name__)
|
LOG = logging.getLogger("." + __name__)
|
||||||
LOG.propagate = True
|
LOG.propagate = True
|
||||||
HAVE_ICU = False
|
HAVE_ICU = False
|
||||||
|
_icu_err = None
|
||||||
_hdlr = None
|
_hdlr = None
|
||||||
# GrampsLocale initialization comes before command-line argument
|
# GrampsLocale initialization comes before command-line argument
|
||||||
# passing, so one must set the log level directly. The default is
|
# passing, so one must set the log level directly. The default is
|
||||||
@ -49,8 +50,10 @@ except ImportError:
|
|||||||
from PyICU import Locale, Collator
|
from PyICU import Locale, Collator
|
||||||
HAVE_ICU = True
|
HAVE_ICU = True
|
||||||
except ImportError as err:
|
except ImportError as err:
|
||||||
LOG.warning("ICU not loaded because %s. Localization will be impaired. "
|
# No logger, save the warning message for later.
|
||||||
"Use your package manager to install PyICU", str(err))
|
_icu_err = ("ICU not loaded because %s. Localization will be impaired. "
|
||||||
|
"Use your package manager to install PyICU" % str(err))
|
||||||
|
|
||||||
ICU_LOCALES = None
|
ICU_LOCALES = None
|
||||||
if HAVE_ICU:
|
if HAVE_ICU:
|
||||||
ICU_LOCALES = Locale.getAvailableLocales()
|
ICU_LOCALES = Locale.getAvailableLocales()
|
||||||
@ -377,6 +380,10 @@ class GrampsLocale(object):
|
|||||||
_hdlr.setFormatter(logging.Formatter(fmt="%(name)s.%(levelname)s: %(message)s"))
|
_hdlr.setFormatter(logging.Formatter(fmt="%(name)s.%(levelname)s: %(message)s"))
|
||||||
LOG.addHandler(_hdlr)
|
LOG.addHandler(_hdlr)
|
||||||
|
|
||||||
|
#Now that we have a logger set up we can issue the icu error if needed.
|
||||||
|
if not HAVE_ICU:
|
||||||
|
LOG.warning(_icu_err)
|
||||||
|
|
||||||
# Even the first instance can be overridden by passing lang
|
# Even the first instance can be overridden by passing lang
|
||||||
# and languages to the constructor. If it isn't (which is the
|
# and languages to the constructor. If it isn't (which is the
|
||||||
# expected behavior), do platform-specific setup:
|
# expected behavior), do platform-specific setup:
|
||||||
|
Loading…
Reference in New Issue
Block a user