<blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;"><span><div><div><div><font color="#a0a0a8"><br></font></div><div>It can't match strings that have already been formatted. It can only do</div><div>so unformatted.</div><div><br></div><div>We have more information in HACKING.rst about why the order matters.</div><div><br></div><div></div></div></div></span></blockquote><div>
<br>
</div><div>I was implying that we could have the logging system do the formatting and i18n for us, rather than just the formatting. Clearly, the i18n would have to be applied before formatting. Perhaps it is better we do this explicitly, but we're also seeing that developers just aren't doing it consistently.</div><div><br></div><div>For example in openstack.common.log, we could do something like:</div><div><br></div><div>+class IntlLogRecord(LogRecord):</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>def getMessage(self):</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>return _(self.msg) % self.args</div><div>+</div><div>+</div><div>+class IntlLogger(logging.Logger):</div><div>+<span class="Apple-tab-span" style="white-space:pre"> </span>def makeRecord(*args):</div><div>+<span class="Apple-tab-span" style="white-space:pre"> rv = </span>Intl<span class="Apple-tab-span" style="white-space:pre">LogRecord(None, None, "", 0, "", (), None, None)
</span>+<span class="Apple-tab-span" style="white-space:pre"> rv.__dict__.update(dict)
</span>+<span class="Apple-tab-span" style="white-space:pre"> return rv</span></div><div>+</div><div>+</div><div> def setup(product_name):<span class="Apple-tab-span" style="white-space:pre"> </span></div><div><div> """Setup logging."""</div><div> sys.excepthook = _create_logging_excepthook(product_name)</div><div><br></div><div>+ logging.setLoggerClass(IntlLogger)</div><div><br></div><div> if CONF.log_config:</div><div> try:</div><div> logging.config.fileConfig(CONF.log_config)</div><div> except Exception:</div><div> traceback.print_exc()</div><div> raise</div><div> else:</div><div> _setup_logging_from_conf(product_name)</div></div><div><br></div><div><div><div>Regards,</div><div>Eric Windisch</div></div><blockquote type="cite" style="border-left-style: solid; border-left-color: rgb(0, 33, 98); color: rgb(0, 33, 98); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; margin-left: 0px; padding-left: 10px; padding-right: 0px; margin-right: 0px; "><span><div><div></div></div></span></blockquote></div>