Translated log files

Registered by Luis A. Garcia

The purpose of this enhancement is to enable OpenStack to generate secondary log files in a specified locale, different from the system's locale, in order to facilitate serviceability in a scenario where a customer runs OS in a language that support personnel may not understand, for example, Chinese customer and US dev/support team.

Blueprint information

Status:
Complete
Approver:
Mark McLoughlin
Priority:
Medium
Drafter:
Luis A. Garcia
Direction:
Approved
Assignee:
Luis A. Garcia
Definition:
Approved
Series goal:
Accepted for icehouse
Implementation:
Implemented
Milestone target:
milestone icon 2014.1
Started by
Luis A. Garcia
Completed by
Luis A. Garcia

Related branches

Sprints

Whiteboard

Using the same strategy used for translated API responses described here https://blueprints.launchpad.net/nova/+spec/user-locale-api in other words, using oslo's gettextutils.Message object we can translate strings that we are logging in order to create a separate log in a different locale than the default log.

The idea is to create a logging Handler, e.g. the TranslationHandler, which would work very similarly to how MemoryHandler works http://docs.python.org/2/library/logging.handlers.html#memoryhandler) in that it would be a helper handler with a target handler.

MemoryHandler has a target handler (which can be any stream handler such as a FileHandler) and it buffers log messages before eventually flushing to the target handler. In the case of the TranslationHandler instead of "buffering" it would "translate" log Messages, before sending the output straight to its target handler.

Using this approach we would have a generic TranslationHandler that could be used as follows in a logging.conf file to create a secondary debug level log file in Chinese, while the default could be info level in English:

    [handlers]
    keys = production, secondary-logfile, translator

    ....

    [handler_secondary-logfile]
    class = handlers.WatchedFileHandler
    level=DEBUG
    args = ('/var/log/nova-dev.log',)
    formatter = context

    [handler_translator]
    class = nova.openstack.common.log.TranslationHandler
    target = secondary-logfile
    args = ('zh_CN',)

---

Current patches:
https://review.openstack.org/#/q/project:openstack/oslo-incubator+branch:master+topic:bp/translated-log-files,n,z

Addressed by: https://review.openstack.org/58375
    New translated log handler

Addressed by: https://review.openstack.org/62508
    Enable setting up translation handler via CONF

Addressed by: https://review.openstack.org/65385
    Add support for zh locales missing from babel

(?)

Work Items

Work items:
- Enable secondary log via additional log handler: DONE
- Enable secondary log via quick config property (e.g. similar to log-file): TODO

This blueprint contains Public information 
Everyone can see this information.