[openstack-dev] [OpenStack-Dev] Logging formats and i18n

Doug Hellmann doug at doughellmann.com
Mon Dec 22 18:05:36 UTC 2014


On Dec 22, 2014, at 12:03 PM, Ben Nemec <openstack at nemebean.com> wrote:

> On 12/22/2014 09:42 AM, John Griffith wrote:
>> Lately (on the Cinder team at least) there's been a lot of
>> disagreement in reviews regarding the proper way to do LOG messages
>> correctly.  Use of '%' vs ',' in the formatting of variables etc.
>> 
>> We do have the oslo i18n guidelines page here [1], which helps a lot
>> but there's some disagreement on a specific case here.  Do we have a
>> set answer on:
>> 
>> LOG.info(_LI('some message: v1=%(v1)s v2=%(v2)s') % {'v1': v1, 'v2': v2})
>> 
>> vs
>> 
>> LOG.info(_LI('some message: v1=%(v1)s v2=%(v2)s'), {'v1': v1, 'v2': v2})
> 
> This is the preferred way.

+1

> 
> Note that this is just a multi-variable variation on
> http://docs.openstack.org/developer/oslo.i18n/guidelines.html#adding-variables-to-log-messages
> and the reasoning discussed there applies.
> 
> I'd be curious why some people prefer the % version because to my
> knowledge that's not recommended even for untranslated log messages.
> 
>> 
>> 
>> It's always fun when one person provides a -1 for the first usage; the
>> submitter changes it and another reviewer gives a -1 and says, no it
>> should be the other way.
>> 
>> I'm hoping maybe somebody on the olso team can provide an
>> authoritative answer and we can then update the example page
>> referenced in [1] to clarify this particular case.
>> 
>> Thanks,
>> John
>> 
>> [1]: http://docs.openstack.org/developer/oslo.i18n/guidelines.html
>> 
>> _______________________________________________
>> OpenStack-dev mailing list
>> OpenStack-dev at lists.openstack.org
>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>> 
> 
> 
> _______________________________________________
> OpenStack-dev mailing list
> OpenStack-dev at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev




More information about the OpenStack-dev mailing list