On Mon, Dec 22, 2014 at 10:03 AM, Ben Nemec <openst...@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.
>
> 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.

Not sure if it's that anybody has a preference as opposed to an
interpretation, notice the recommendation for multi-vars in raise:

# RIGHT
raise ValueError(_('some message: v1=%(v1)s v2=%(v2)s') % {'v1': v1, 'v2': v2})

>
>>
>>
>> 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@lists.openstack.org
>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>>
>
>
> _______________________________________________
> OpenStack-dev mailing list
> OpenStack-dev@lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

_______________________________________________
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

Reply via email to