Hello all,

My logging obsession continues.  I have submitted a giant PR
(https://github.com/apache/mynewt-core/pull/1249) which changes all
existing packages to use the modlog facility rather than directly call
into the `sys/log` API.  I think this is the right direction, but it is
a somewhat major change, and I am certainly open to feedback.

I see two benefits of this change:

* For simple logging to the console, apps don't need to define and
  register a log.  Just use `MODLOG_DFLT` to log a message.

* Most packages don't need to define and expose a log object, and the
  application doesn't need to register it.  The package just writes log
  messages to its reserved log module ID.  This eliminates the need for
  every app to register the `ble_hs_log` and `oc_log` log objects, for
  example.

Here is what I personally would like to see in Mynewt, going forward:

1. Every package uses modlog; nothing uses the log API directly
(except for modlog itself :) ).

2. Applications that just want to log to the console just use the
`MODLOG_DFLT` macro.  This macro writes a printf-style string to the
"default" module, which routes to the console unless remapped.

3. If a library needs to log messages, it defines a log module syscfg
setting for each module it uses.  It is important that syscfg is used
here so that the user can override them in case two packages choose the
same module ID(s).

4. Newt adds two new syscfg setting types:
    * log_module_owner
    * log_module

`log_module_owner` is used to stake out a unique module ID.  If two
`log_module_owner` settings specify the same number, that indicates a
conflict in the module number space, and newt can abort the build with a
meaningful error.

`log_module` is used when a package wants to log to "someone else's"
module.  Newt doesn't complain if one or more `log_module` settings have
the same value as a `log_module_owner` setting.

A new command would be added to newt to display all assigned log module
IDs in a target.

All comments welcome.

Thanks,
Chris

Reply via email to