[bind10-dev] Questions on the Logging API

Stephen Morris stephen at isc.org
Thu Dec 16 15:06:19 UTC 2010


Before going too far with the logging API, I thought I'd get some feedback concerning the use of external message files.

The ideas behind this are more fully explained in http://bind10.isc.org/wiki/ExternalMessageFiles but, but in essence, if we are going to allow for internationalization by giving users the ability to customise the messages, we need to have the messages collected in one place rather than scattered throughout the code.  We could put all the strings in one or more modules and let the users make changes there, but this would make it awkward when we upgrade BIND-10; it would be a lot of work for users to maintain their customisations should we add or remove message definitions.  For this reason, I propose that we write a "message compiler" which is called during the build process and merges local customisations with the distributed files.  For example, running the compiler with a command of the form:

    message <distributed-file.msg> [<user-file.msg>]

The message definitions in distributed-file.msg are used unless overridden by a definition in user-file.msg.

A consequence of this indirection is that instead of including literal text within the source code, we would now refer to the messages by symbolic name.  This has certain implications, hence the following questions (background information can be found in the wiki: http://bind10.isc.org/wiki/ExternalMessageFiles):

1. In C++, should the symbols be "const char*" or should they be numbers?

2. Should we use this scheme for C++ exception messages?

If so, we would need to change the way exceptions are thrown.  At present we have:

      isc_throw(exception_class, stream)

… where "stream" can be output with a construct of the form "oss << steam".  This has allowed us to write things like:

      isc_throw(InvalidTime, "Invalid " << valname << "value: " << value);

With an external message file we would need to move away from the stream format (as it allows the splitting a the text of a message into multiple fragments, e.g. "Invalid" and "value: " in the example above) and instead write something like:

      isc_throw(InvalidTime, INVALTIME, valname, value)

Is this a change we want to make?

3. Is there a need for C++ and Python to communicate information about message codes (e.g. Python module passes a code to C++ that the latter interprets and outputs)?

(If yes, we would need to define both C++ and Python symbols as either integers or strings.  If not, we could have different implementations  - C++ defines the symbols as numbers, Python as strings.)


Thoughts?

Stephen


More information about the bind10-dev mailing list