oslo_i18n package¶
Submodules¶
oslo_i18n.fixture module¶
oslo_i18n.log module¶
logging utilities for translation
- class oslo_i18n.log.TranslationHandler(locale=None, target=None)¶
Bases:
logging.handlers.MemoryHandler
Handler that translates records before logging them.
When lazy translation is enabled in the application (see
enable_lazy()
), theTranslationHandler
uses its locale configuration setting to determine how to translate LogRecord objects before forwarding them to the logging.Handler.When lazy translation is disabled, the message in the LogRecord is converted to unicode without any changes and then forwarded to the logging.Handler.
The handler can be configured declaratively in the
logging.conf
as follows:[handlers] keys = translatedlog, translator [handler_translatedlog] class = handlers.WatchedFileHandler args = ('/var/log/api-localized.log',) formatter = context [handler_translator] class = oslo_i18n.log.TranslationHandler target = translatedlog args = ('zh_CN',)
If the specified locale is not available in the system, the handler will log in the default locale.
- emit(record)¶
Emit a record.
Append the record. If shouldFlush() tells us to, call flush() to process the buffer.
- setFormatter(fmt)¶
Set the formatter for this handler.