All logs are associated with a single channel, however there a variety of ways of subscribing to a log message.
rDebug("hi"); // same as static RLogChannel *myChannel = DEF_CHANNEL("debug", Log_Debug); rLog(myChannel, "hi");
In the example above, all subscribers to the "debug" channel receive the messages, but not subscribers to "debug/foo" or other sub-channels.
If a log is published under "debug/foo/bar":
static RLogChannel *myChannel = DEF_CHANNEL("debug/foo/bar", Log_Debug); rLog(myChannel, "hi");
In that example, all subscribers to "debug/foo/bar", "debug/foo", and "debug" will receive the message.
All channels are considered to be derived from a root channel. It doesn't have a true name and is referenced as the empty string "". So, to capture all messages:
// capture all messages and log them to stderr StdioNode stdLog( STDERR_FILENO ); stdLog.subscribeTo( GetGlobalChannel("") ); // empty string is root channel
Channels are componentized. By default, all log messages using one of the rLog type macros is actually published on the component-specific version of the channel. So, instead of just saying it was published on "debug" channel, we need to also say which component it was part of, which we could represent as a pair ( < COMPONENT, CHANNEL > ) -- eg <"myComponent", "debug">.
This means that two separate components, both using rDebug() (for example) could be subscribed to separately, or together.
There is a way to subscribe to channels in the following ways:
{ StdioNode stdLog( STDERR_FILENO ); // subscribe to a particular channel from a component stdLog.subscribeTo( RLOG_CHANNEL("debug/foo") ); // subscribe to all channels from a component // the root channel for our component (root is empty string "") stdLog.subscribeTo( RLOG_CHANNEL("") ); // subscribe to a channel from all components stdLog.subscribeTo( GetGlobalChannel("debug/foo") ); // subscribe to all channels from all components stdLog.subscribeTo( GetGlobalChannel("") ); }
As you can see from the pattern above, using the RLOG_CHANNEL() macro limits the selection to the current component. If you want to specify a component other then the current component, use GetComponentChannel() which takes the component name as the first argument.