BDE 4.14.0 Production release
|
Enumerate the set of states for log record transmission.
This component provides a namespace, ball::Transmission
, for the enum
type ball::Transmission::Cause
. Cause
enumerates the list of conditions (or states) that can cause a log record to be transmitted. In addition, this component supports functions that convert the Cause
enumerators to a well-defined ASCII representation.
This section illustrates intended use of this component.
The following snippets of code provide a simple illustration of ball::Transmission
usage.
First create a variable cause
of type ball::Transmission::Cause
and initialize it to the value ball::Transmission::e_TRIGGER_ALL
:
Next, store a pointer to its ASCII representation in a variable asciiCause
of type const char *
:
Finally, print the value of cause
to bsl::cout
.
This statement produces the following output on stdout
:
The Cause
enumeration defined in this component allows a logging system to describe the condition causing the publication of a log message. One possible interpretation of three of these conditions is as follows:
e_PASSTHROUGH
: indicate that a message is being output as a stand-alone message.
e_TRIGGER
: indicate that a message is being output as part of a dump of all messages archived for the current thread.
e_TRIGGER_ALL
: indicate that a message is being output as part of a dump of all messages archived for all threads.
This example illustrates the use of ball::Transmission::Cause
by a hypothetical logging system.
We define a simple logger class named my_Logger
. Assume that my_Logger
accepts messages from clients (e.g., the threads in a multi-threaded application) and archives them in-core. Further assume that the message archive is bounded in size in which case my_Logger
removes older messages to make room for newer ones as the need arises. When a thread encounters an unusual, unexpected, or undesirable condition that it wishes to bring to the attention of an operator (say, sitting at a console terminal), it "publishes" the message. That is the role of the publish
method in the interface of my_Logger
:
The publish
method, defined in the following, shows the different actions that are taken for the three distinct causes of log message publication:
Finally, we create a my_Logger
object and publish
three (simplistic) messages, each with a different cause:
The following output is produced on stdout
: